---
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"}]}" />

### Hidden label

<Dropdown hideLabel 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" />

### Top direction

Set `direction` to `"top"` for the dropdown menu to appear above the input.

<Dropdown direction="top" titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
  {id: "1", text: "Email"},
  {id: "2", text: "Fax"}]}" />

### Light variant

<Dropdown light titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
  {id: "1", text: "Email"},
  {id: "2", text: "Fax"}]}" />

### Inline variant

<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"}]}" />

### Invalid state

<Dropdown invalid invalidText="Secondary contact method must be different from the primary contact" titleText="Contact" selectedIndex={0} items="{[{id: "0", text: "Slack"},
  {id: "1", text: "Email"},
  {id: "2", text: "Fax"}]}" />

### Warning state

<Dropdown warn warnText="This contact method is not associated with your account" 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 />