Dropdown Menu
Displays a menu to the user, such as a set of actions or functions, triggered by a button.
Installation
pnpm add @heyramzi/ui bits-uiUsage
import * as DropdownMenu from "@heyramzi/ui/shadcn/dropdown-menu";<DropdownMenu.Root>
<DropdownMenu.Trigger>Open</DropdownMenu.Trigger>
<DropdownMenu.Content align="start">
<DropdownMenu.Label>My account</DropdownMenu.Label>
<DropdownMenu.Group>
<DropdownMenu.Item>
Profile
<DropdownMenu.Shortcut>⇧⌘P</DropdownMenu.Shortcut>
</DropdownMenu.Item>
<DropdownMenu.Item>Billing</DropdownMenu.Item>
</DropdownMenu.Group>
<DropdownMenu.Separator />
<DropdownMenu.Item>Log out</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>Keyboard and accessibility
| Key | Does |
|---|---|
| Space Enter | On the trigger, opens the menu. On an item, runs it. |
| Arrow Down | On the trigger, opens the menu on its first item. In the menu, moves to the next item. |
| Arrow Up | Moves to the previous item. |
| Home | Moves to the first item. |
| End | Moves to the last item. |
| Arrow Right | On a submenu trigger, opens the submenu. |
| Arrow Left | In a submenu, closes it. |
| Esc | Closes the menu and returns focus to the trigger. |
- Typing a letter jumps to the next item whose label starts with it.
- Checkbox and radio items report checked.
- Disabled items are skipped by the arrow keys.
API reference
DropdownMenu.CheckboxGroup
refbindableHTMLElement | null- Default
null valuebindableDropdownMenu.CheckboxGroup- Default
[] ...rest- Every prop of
DropdownMenu.CheckboxGroupfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
value bindable | DropdownMenu.CheckboxGroup | [] |
...rest | Every prop of DropdownMenu.CheckboxGroup from bits-ui | |
DropdownMenu.Trigger
refbindableHTMLElement | null- Default
null ...rest- Every prop of
DropdownMenu.Triggerfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
...rest | Every prop of DropdownMenu.Trigger from bits-ui | |
DropdownMenu.Content
portalPropsWithoutChildrenOrChild<ComponentProps<typeof DropdownMenuPortal>>refbindableHTMLElement | null- Default
null sideOffsetnumber- Default
4 alignstring- Default
"start" collisionPaddingnumber- Default
8 classstring...rest- Every prop of
DropdownMenu.Contentfrombits-ui
| Prop | Type | Default |
|---|---|---|
portalProps | WithoutChildrenOrChild<ComponentProps<typeof DropdownMenuPortal>> | |
ref bindable | HTMLElement | null | null |
sideOffset | number | 4 |
align | string | "start" |
collisionPadding | number | 8 |
class | string | |
...rest | Every prop of DropdownMenu.Content from bits-ui | |
DropdownMenu.Label
insetbooleanrefbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
inset | boolean | |
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
DropdownMenu.Group
refbindableHTMLElement | null- Default
null ...rest- Every prop of
DropdownMenu.Groupfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
...rest | Every prop of DropdownMenu.Group from bits-ui | |
DropdownMenu.Item
insetbooleanvariant"default" | "destructive"- Default
"default" refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
DropdownMenu.Itemfrombits-ui
| Prop | Type | Default |
|---|---|---|
inset | boolean | |
variant | "default" | "destructive" | "default" |
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of DropdownMenu.Item from bits-ui | |
DropdownMenu.Shortcut
refbindableHTMLSpanElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLSpanElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLSpanElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements | |
DropdownMenu.Separator
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
DropdownMenu.Separatorfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of DropdownMenu.Separator from bits-ui | |
DropdownMenu.Sub
openbindableboolean- Default
false ...rest- Every prop of
DropdownMenu.Subfrombits-ui
| Prop | Type | Default |
|---|---|---|
open bindable | boolean | false |
...rest | Every prop of DropdownMenu.Sub from bits-ui | |
DropdownMenu.SubTrigger
insetbooleanrefbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
DropdownMenu.SubTriggerfrombits-ui
| Prop | Type | Default |
|---|---|---|
inset | boolean | |
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of DropdownMenu.SubTrigger from bits-ui | |
DropdownMenu.SubContent
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
DropdownMenu.SubContentfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of DropdownMenu.SubContent from bits-ui | |
DropdownMenu.CheckboxItem
childrenSnippetrefbindableHTMLElement | null- Default
null checkedbindableboolean- Default
false indeterminatebindableboolean- Default
false classstring...rest- Every prop of
DropdownMenu.CheckboxItemfrombits-uiexceptchild, children
| Prop | Type | Default |
|---|---|---|
children | Snippet | |
ref bindable | HTMLElement | null | null |
checked bindable | boolean | false |
indeterminate bindable | boolean | false |
class | string | |
...rest | Every prop of DropdownMenu.CheckboxItem from bits-ui except child, children | |
DropdownMenu.Portal
...rest- Every prop of
DropdownMenu.Portalfrombits-ui
| Prop | Type | Default |
|---|---|---|
...rest | Every prop of DropdownMenu.Portal from bits-ui | |
DropdownMenu.DropdownMenu
openbindableboolean- Default
false ...rest- Every prop of
DropdownMenu.Rootfrombits-ui
| Prop | Type | Default |
|---|---|---|
open bindable | boolean | false |
...rest | Every prop of DropdownMenu.Root from bits-ui | |
DropdownMenu.RadioGroup
refbindableHTMLElement | null- Default
null valuebindableDropdownMenu.RadioGroup...rest- Every prop of
DropdownMenu.RadioGroupfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
value bindable | DropdownMenu.RadioGroup | |
...rest | Every prop of DropdownMenu.RadioGroup from bits-ui | |
DropdownMenu.RadioItem
refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
DropdownMenu.RadioItemfrombits-uiexceptchild
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of DropdownMenu.RadioItem from bits-ui except child | |
DropdownMenu.GroupHeading
insetbooleanrefbindableHTMLElement | null- Default
null classstring...rest- Every prop of
DropdownMenu.GroupHeadingfrombits-ui
| Prop | Type | Default |
|---|---|---|
inset | boolean | |
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of DropdownMenu.GroupHeading from bits-ui | |