Skip to content
Nana UI

Forms & Inputs

Dropdown

A trigger that reveals a panel of options — single or multi-select, optionally searchable. Compose it from nana-option children (use nana-menu-label for groups). Flips above the trigger when it would overflow.

View .md Download
Ada Lovelace Alan Turing Paula Hawkins

A dropdown ships for all three targets, but they are not the same component — see the note below. Pick the tab for your project — the CLI detects which you are on and serves the matching implementation.

npx @nana-tec/ui add dropdown

Lands as src/components/ui/dropdown/dropdown.tsx, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

Add the searchable attribute to filter options as you type.

United States Canada Mexico

Set select="multiple" to allow multiple selections.

React Vue Svelte

Use nana-menu-label to group options.

Design Ada Lovelace Engineering Alan Turing
import {
Dropdown, DropdownItem, DropdownLabel, DropdownSeparator,
} from "@/components/ui/dropdown";
import { Button } from "@/components/ui/button";
export function Example() {
return (
<Dropdown trigger={<Button variant="ghost">Actions</Button>} align="end">
<DropdownLabel>Manage</DropdownLabel>
<DropdownItem onClick={rename}>Rename</DropdownItem>
<DropdownItem onClick={duplicate}>Duplicate</DropdownItem>
<DropdownSeparator />
<DropdownItem destructive onClick={remove}>Delete</DropdownItem>
</Dropdown>
);
}

This is an action menu: role="menu" with role="menuitem" children. It closes on Escape, on an outside click, and after an item is chosen, and returns focus to the trigger.

Classes you pass to the React and Svelte components are merged with tailwind-merge, so an override wins rather than fighting. See Using Tailwind.

The React and Svelte props, read from the components’ own types:

Dropdown

PropTypeDefault
triggerrequiredReactNode
alignDropdownAlign'start'
labelstring
childrenReactNode

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'children'>.

DropdownItem

PropTypeDefault
destructivebooleanfalse

Also accepts ButtonHTMLAttributes<HTMLButtonElement>.

The attribute names, events and CSS hooks below are the Web Components reference.

Properties

PropertyAttributeTypeDefaultDescription
disableddisabledbooleanfalseDisable the dropdown
labellabelstring'Select'Trigger label / placeholder (default trigger only)
openopenbooleanfalseOpen state
searchablesearchablebooleanfalseShow a search field that filters the options
selectselectDropdownSelect'single'Single or multiple selection
valuevaluestring''Selected value(s) — comma-separated for multiple

Events

EventDescription
nana-changeFired on selection (detail.value — string or string[])

Slots

SlotDescription
triggerCustom trigger element (falls back to a default button)
(default)nana-option / nana-menu-label children

CSS parts

PartDescription
::part(panel)The floating options panel

CSS custom properties

PropertyDescription
--nana-dropdown-max-heightPanel max height before scrolling
--nana-dropdown-zStacking order for the floating panel
EventTypeDescription
nana-changeCustomEventFired on selection (detail.value — string or string[])
SlotDescription
triggerCustom trigger element (falls back to a default button)
(default)nana-option / nana-menu-label children
VariableDescription
--nana-dropdown-max-heightPanel max height before scrolling
PartDescription
panelThe floating options panel

The React and Svelte dropdown is a menu, and takes its keyboard from the shared menu rules:

KeyOn the triggerIn the menu
↓ Enter SpaceOpens, focus on the first itemNext item, wrapping
↑Opens, focus on the last itemPrevious item, wrapping
Home End—First / last item
A–Z—Jumps to the next item starting with that letter; press again to cycle
Escape—Closes, focus returns to the trigger
Tab—Closes, focus carries on past the menu

nana-dropdown is a listbox rather than a menu, so it reads the listbox rules instead: arrows walk and wrap, Home and End jump, Enter chooses, Escape closes. Its search field replaces typeahead, and takes Home and End for the caret while it has focus.

  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Dropdown interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook