Overview
Reference usage
Composite dropdown root that coordinates the trigger, menu, and item subcomponents.
Usage
Dropdown is a compound component. Import the parent and compose its leaves via the namespace API: Dropdown.Trigger, Dropdown.Menu, Dropdown.Item, Dropdown.Label, Dropdown.Separator, and Dropdown.Group.
The menu reads as a modern menu (COR-2681). A row is 32px on a fine pointer and 44px on a touch screen, and items and group labels share one 8px inset. Hover, keyboard focus and press are a neutral ink overlay that shows on the raised menu in both themes. Items draw no hairline between them: put a Dropdown.Separator where a menu needs a division. A radio or checkbox item keeps a check column only as wide as the mark, and the label of a group of them starts where their text starts, past a leading icon when the items carry one. An anchored menu lines its panel's edge up with the trigger's edge, and its item text sits at the 8px inset: it does not follow the trigger's label, which pads further in.
The leaves are also named exports of @lostgradient/cinder.
The trigger shrinks to fit its container. For a long trigger label, wrap the text in an element that truncates itself with min-inline-size: 0, overflow: hidden, text-overflow: ellipsis and white-space: nowrap.
Dropdown supports two mutually exclusive APIs: the compound Dropdown.Trigger/Dropdown.Menu composition shown above, and a legacy trigger/open snippet-prop API. Do not mix the two on the same instance.
id is optional (auto-generated) only for the legacy trigger/open API. The compound Dropdown.Trigger/Dropdown.Menu API requires id explicitly.
When to use
- Composing a menu of actions or links revealed by clicking a button trigger.
- Building a custom dropdown layout from dropdown-trigger, dropdown-menu, dropdown-item, dropdown-label, and dropdown-separator parts.
- Selecting a value from a list of options — use select or combobox instead.
- Showing supplementary content rather than a menu of choices — use popover.
Examples
Basic dropdown
A button trigger with a list of menu items.
Placement
Use bottom-start or bottom-end placement to align the menu with whichever trigger edge fits the surrounding layout.
With clickable items
Dropdown.Item accepts onclick handlers and a danger variant for destructive actions.
With group labels
Dropdown.Group and Dropdown.Label expose accessible group boundaries for related menu actions.
With separators
Dropdown.Separator divides menu item groups; useful before destructive actions.
Props
Name | Type | Default | Description |
|---|---|---|---|
id | text | ||
open bindable | boolean | false | Controls the open state of the dropdown menu; bindable for controlled usage. |
placement | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'bottom-start' | Preferred menu placement relative to the trigger. Default bottom-start.
The rendered menu may still flip to stay within the viewport. |
sheetBelow | text | Viewport width below which the menu docks to the bottom edge as a sheet,
with the bottom Drawer's geometry, instead of anchoring to its trigger.
Keyboard, focus, and dismissal behave exactly as when anchored. A simple
CSS length such as '640px', or false to always anchor. Default
'640px'. | |
trigger | snippet | ||
children | snippet |