Skip to main content
Tw Twintrinsic
  • Getting Started
  • Components
  • Theming
  • Completion
Examples
Data Dashboard Game Map
Core
App
Layout
Accordion AccordionItem Card Container Panel Separator Sidebar Splitter
Navigation
AppHeader BottomBar Breadcrumb BreadcrumbItem Menu MenuItem Tabs Tab TabList TabPanel TreeMenu
Data Display
Avatar AvatarGroup Badge Carousel CarouselItem Chip ChipGroup CodeBlock CodeBlockSpeed CodeEditor DataTable Map Progress Skeleton Table TableBody TableCell TableHead TableHeader TableRow Tag TagGroup Timeline TimelineItem Tooltip Tree TreeNode
Metrics
DonutChart PieChart LineChart BarChart HorizontalBarChart AreaChart StatsCard MetricGrid KPICard GaugeChart ProgressMetric MetricTrend
Form
AutoComplete Button ButtonGroup Calendar Checkbox ColorPicker Combobox Dropdown FileUpload FloatLabel Form FormField Input InputSwitch InvalidState Knob ListInput Listbox NumberInput Radio RadioGroup Rating Select SelectGroup Slider Switch TextInput Textarea
Feedback
Modal Stepper StepperStep Toast
Utility
Icon Lazy LazyPanel Masonry ThemeToggle

Dropdown

The Dropdown component provides a way to select one or multiple options from a dropdown menu. It supports icons, option groups, cascading menus, filtering, and keyboard navigation.

Examples

Basic Usage

<Dropdown 
  options={['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry']}
  placeholder="Select a fruit"
/>

With Object Options

const countries = [
  { label: 'United States', value: 'us' },
  { label: 'United Kingdom', value: 'uk' },
  { label: 'Canada', value: 'ca' }
]

<Dropdown 
  options={countries}
  placeholder="Select a country"
/>

Multiple Selection

const skills = [
  { label: 'JavaScript', value: 'js' },
  { label: 'TypeScript', value: 'ts' },
  { label: 'Svelte', value: 'svelte' },
  { label: 'React', value: 'react' },
  { label: 'Vue', value: 'vue' }
]

<Dropdown 
  options={skills}
  placeholder="Select skills"
  multiple={true}
/>

With Icons

const countries = [
  { 
    label: 'United States', 
    value: 'us', 
    icon: '<svg>...</svg>' 
  },
  { 
    label: 'United Kingdom', 
    value: 'uk', 
    icon: '<svg>...</svg>' 
  },
  { 
    label: 'Canada', 
    value: 'ca', 
    icon: '<svg>...</svg>' 
  }
]

<Dropdown 
  options={countries}
  placeholder="Select a country"
  optionIcon="icon"
/>

Cascading Dropdown

const categories = [
  { 
    name: 'Frontend', 
    id: 'frontend',
    items: [
      { name: 'HTML', id: 'html' },
      { name: 'CSS', id: 'css' },
      { name: 'JavaScript', id: 'js' }
    ]
  },
  { 
    name: 'Backend', 
    id: 'backend',
    items: [
      { name: 'Node.js', id: 'node' },
      { name: 'Python', id: 'python' },
      { name: 'Java', id: 'java' }
    ]
  }
]

<Dropdown 
  options={categories}
  placeholder="Select a category"
  optionLabel="name"
  optionValue="id"
  optionChildren="items"
/>

With Filtering

<Dropdown 
  options={skills}
  placeholder="Search and select skills"
  filter={true}
/>

Different Sizes

<Dropdown 
  options={['Small', 'Medium', 'Large']}
  placeholder="Small"
  size="sm"
/>
<Dropdown 
  options={['Small', 'Medium', 'Large']}
  placeholder="Medium"
  size="md"
/>
<Dropdown 
  options={['Small', 'Medium', 'Large']}
  placeholder="Large"
  size="lg"
/>

Clearable

<Dropdown 
  options={countries}
  placeholder="Select a country"
  clearable={true}
/>

Disabled State

<Dropdown 
  options={countries}
  placeholder="Select a country"
  disabled={true}
/>

Props

PropTypeDefaultDescription
optionsArray[]Options to display in the dropdown
valueanyRequiredSelected value(s)
placeholderstring'Select an option'Placeholder text when no option is selected
multiplebooleanfalseWhether multiple selection is allowed
optionLabelstring'label'Property name for option label when using object options
optionValuestring'value'Property name for option value when using object options
optionIconstringRequiredProperty name for option icon when using object options
optionChildrenstring'items'Property name for option children (for cascading dropdowns)
disabledbooleanfalseWhether the dropdown is disabled
requiredbooleanfalseWhether the dropdown is required
filterbooleanfalseWhether to enable filtering options by typing
size'sm' | 'md' | 'lg''md'Size of the dropdown
clearablebooleanfalseWhether to show a clear button
namestringRequiredName attribute for form submission
ariaLabelstringRequiredARIA label for accessibility
idstringauto-generatedHTML id for accessibility
classstring''Additional CSS classes

Events

EventDetail TypeDescription
onchange{ value: any }Fired when the selected value changes
onclearEventFired when the selection is cleared

Accessibility

The Dropdown component follows WAI-ARIA guidelines for combobox and listbox elements:

  • Uses appropriate ARIA roles (combobox, listbox, option)
  • Provides proper keyboard navigation
  • Manages focus appropriately
  • Includes proper ARIA attributes for expanded state and selection
  • Supports screen readers with appropriate labels and descriptions

Keyboard Interaction

  • Space or Enter - Open/close dropdown and select highlighted option
  • ArrowDown - Open dropdown or move to next option
  • ArrowUp - Move to previous option
  • ArrowRight - Open submenu (for cascading dropdowns)
  • ArrowLeft - Close submenu (for cascading dropdowns)
  • Escape - Close dropdown
  • Tab - Move focus away from dropdown
  • Home - Move to first option
  • End - Move to last option