mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 19:01:05 +00:00
62 lines
No EOL
1.6 KiB
Text
62 lines
No EOL
1.6 KiB
Text
---
|
|
components: ["Dropdown", "DropdownSkeleton"]
|
|
---
|
|
|
|
<script>
|
|
import { Dropdown, DropdownSkeleton } from "carbon-components-svelte";
|
|
import Preview from "../../components/Preview.svelte";
|
|
</script>
|
|
|
|
### Default
|
|
|
|
<Dropdown titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
|
|
{id: "1", text: "Email"},
|
|
{id: "2", text: "Fax"}]}" />
|
|
|
|
### Format item display text
|
|
|
|
Use the `itemToString` prop to format the display of individual items.
|
|
|
|
<Dropdown itemToString={item => {
|
|
return item.text + ' (' + item.id +')'
|
|
}} titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
|
|
{id: "1", text: "Email"},
|
|
{id: "2", text: "Fax"}]}" />
|
|
|
|
### Multiple dropdowns
|
|
|
|
<FileSource src="/framed/Dropdown/MultipleDropdown" />
|
|
|
|
### Light variant
|
|
|
|
<Dropdown light titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
|
|
{id: "1", text: "Email"},
|
|
{id: "2", text: "Fax"}]}" />
|
|
|
|
### Inline type
|
|
|
|
<Dropdown type="inline" titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
|
|
{id: "1", text: "Email"},
|
|
{id: "2", text: "Fax"}]}" />
|
|
|
|
### Extra-large size
|
|
|
|
<Dropdown size="xl" titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
|
|
{id: "1", text: "Email"},
|
|
{id: "2", text: "Fax"}]}" />
|
|
|
|
### Small size
|
|
|
|
<Dropdown size="sm" titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
|
|
{id: "1", text: "Email"},
|
|
{id: "2", text: "Fax"}]}" />
|
|
|
|
### Disabled state
|
|
|
|
<Dropdown disabled titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
|
|
{id: "1", text: "Email"},
|
|
{id: "2", text: "Fax"}]}" />
|
|
|
|
### Skeleton
|
|
|
|
<DropdownSkeleton /> |