Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

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-ui

Usage

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

ref bindable HTMLElement | null
Default null
value bindable DropdownMenu.CheckboxGroup
Default []
...rest
Every prop of DropdownMenu.CheckboxGroup from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
value bindable DropdownMenu.CheckboxGroup []
...rest Every prop of DropdownMenu.CheckboxGroup from bits-ui

DropdownMenu.Trigger

ref bindable HTMLElement | null
Default null
...rest
Every prop of DropdownMenu.Trigger from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
...rest Every prop of DropdownMenu.Trigger from bits-ui

DropdownMenu.Content

portalProps WithoutChildrenOrChild<ComponentProps<typeof DropdownMenuPortal>>
ref bindable HTMLElement | null
Default null
sideOffset number
Default 4
align string
Default "start"
collisionPadding number
Default 8
class string
...rest
Every prop of DropdownMenu.Content from bits-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

inset boolean
ref bindable HTMLDivElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLDivElement> from svelte/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

ref bindable HTMLElement | null
Default null
...rest
Every prop of DropdownMenu.Group from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
...rest Every prop of DropdownMenu.Group from bits-ui

DropdownMenu.Item

inset boolean
variant "default" | "destructive"
Default "default"
ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of DropdownMenu.Item from bits-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

ref bindable HTMLSpanElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements
Prop Type Default
ref bindable HTMLSpanElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements

DropdownMenu.Separator

ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of DropdownMenu.Separator from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
...rest Every prop of DropdownMenu.Separator from bits-ui

DropdownMenu.Sub

open bindable boolean
Default false
...rest
Every prop of DropdownMenu.Sub from bits-ui
Prop Type Default
open bindable boolean false
...rest Every prop of DropdownMenu.Sub from bits-ui

DropdownMenu.SubTrigger

inset boolean
ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of DropdownMenu.SubTrigger from bits-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

ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of DropdownMenu.SubContent from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
...rest Every prop of DropdownMenu.SubContent from bits-ui

DropdownMenu.CheckboxItem

children Snippet
ref bindable HTMLElement | null
Default null
checked bindable boolean
Default false
indeterminate bindable boolean
Default false
class string
...rest
Every prop of DropdownMenu.CheckboxItem from bits-ui except child, 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.Portal from bits-ui
Prop Type Default
...rest Every prop of DropdownMenu.Portal from bits-ui

DropdownMenu.DropdownMenu

open bindable boolean
Default false
...rest
Every prop of DropdownMenu.Root from bits-ui
Prop Type Default
open bindable boolean false
...rest Every prop of DropdownMenu.Root from bits-ui

DropdownMenu.RadioGroup

ref bindable HTMLElement | null
Default null
value bindable DropdownMenu.RadioGroup
...rest
Every prop of DropdownMenu.RadioGroup from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
value bindable DropdownMenu.RadioGroup
...rest Every prop of DropdownMenu.RadioGroup from bits-ui

DropdownMenu.RadioItem

ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of DropdownMenu.RadioItem from bits-ui except child
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

inset boolean
ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of DropdownMenu.GroupHeading from bits-ui
Prop Type Default
inset boolean
ref bindable HTMLElement | null null
class string
...rest Every prop of DropdownMenu.GroupHeading from bits-ui