Skip to content
Overlays

DropdownMenu

An anchored menu with full keyboard control.

import
import { DropdownMenu, MenuItem, MenuLabel, MenuSeparator } from '@joshicodes/cock';

Menu

Keyboard

↑ ↓
Moves between items, wrapping at the ends
Home / End
First and last item
Esc
Closes and returns focus to the trigger
Tab
Closes and moves on

Behaviour

  • Renders into `<body>` and positions itself against its trigger, so an `overflow: hidden` ancestor or a scrolling table cannot clip it.
  • Opening with the mouse or the keyboard focuses the first item either way.

API

Read out of the component sources at build time, so it matches the version you installed. Every component also takes class, merged through tailwind-merge so your utility wins.

<DropdownMenu>

Props

PropTypeDefault
open bindable
booleanfalse
placement
Placement'bottom-start'
offset
number6
class
string—
label
string'Menu'

Snippets

SnippetTypeDefault
trigger required
Snippet<[TriggerAttrs]>—
children required
Snippet—

<MenuItem>

Props

PropTypeDefault
href

Render as a link instead of a button.

string—
disabled
booleanfalse
variant
'default' | 'danger''default'
hint

Trailing hint, e.g. a keyboard shortcut.

string—
class
string—

Snippets

SnippetTypeDefault
icon

Leading icon slot.

Snippet—
children
Snippet—

Events

EventTypeDefault
onselect
() => void—

<MenuLabel>

Props

PropTypeDefault
class
string—

Snippets

SnippetTypeDefault
children
Snippet—

<MenuSeparator>

Props

PropTypeDefault
class
string—

See also

cock. Yes, it stands for core component kit. We checked twice.