Aliases
action menu
components / menu
Data-driven action list with highlight, selection, and overlay containment.
Playground
Start here. Switch systems, interact with the shipped component, and let the rest of the page answer the why and how after the behavior clicks.
Cobalt
The crisp default DK action system: bright primary, roomy spacing, and a direct editorial rhythm.
Overview
This section explains the intent of the component before the implementation details.
Aliases
action menu
Explore the math
Decision guide
Use these notes to decide quickly whether this is the right DK component for the job.
Decision guide
Do
Do not
Usage
Prefer these situations when choosing this component.
Usage
These patterns are better served by a different component or a simpler surface.
Anti-patterns
Migration notes
Anatomy
The anatomy explains which pieces matter to the recipe and accessibility model.
open affordance
triggerOpens the menu surface.
menu overlay
surfaceContains the action list.
menu item
itemSelectable action row.
API
The docs contract distinguishes props, DOM events, and slots so integration behavior is explicit.
Props
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Controlled open state. |
items | Array<{ value: string; label: string; shortcut?: string; disabled?: boolean; destructive?: boolean }> | — | Menu item definitions. |
placement | 'top' | 'right' | 'bottom' | 'left' | 'bottom' | Preferred anchor placement. |
size | 'sm' | 'md' | 'md' | Chooses the menu size recipe. |
onOpenChange | (detail: { open: boolean }) => void | — | Callback fired when the menu opens or closes. |
onAction | (detail: { id?: string; value?: string }) => void | — | Callback fired when a menu item is selected. |
theme | ThemeContract | — | Overrides the compiled DK theme used to resolve tokens and recipes for this component. |
Events
| Name | Payload | Description |
|---|---|---|
openchange | { open: boolean } | Fires when an overlay-style component opens or closes through user interaction. |
action | { id?: string; value?: string } | Fires when the component exposes a primary action and the user activates it. |
Slots
| Name | Description |
|---|---|
trigger | Trigger content for the menu. |
Recipes
These notes summarize the intended recipe surface rather than exposing raw implementation detail first.
Variants
Sizes
States
Accessibility
This is the behavior the component promises to assistive tech and keyboard users today.
Semantics
Keyboard
Screen readers
Checklist
Implementation
This section shows the representative compiled slot variables that the runtime consumes for the selected design system.
Implementation notes
Implementation checklist
Examples
Each example is intentionally practical, grouped by starter, common pattern, and edge-case coverage.
Starter
1 example
starter
Starter: contextual action listA short anchored action menu.
Copy snippet
<Menu items={[{ value: 'rename', label: 'Rename' }, { value: 'archive', label: 'Archive', destructive: true }]}><svelte:fragment slot="trigger">Open menu</svelte:fragment></Menu>Common patterns
1 example
common
Common: shortcut-aware menuShortcuts help power users scan faster.
Copy snippet
<Menu items={[{ value: 'duplicate', label: 'Duplicate', shortcut: '⌘D' }, { value: 'archive', label: 'Archive', shortcut: '⌘⌫' }]} />Edge cases
1 example
edge
Edge: externally controlled menuControl open state when a larger workflow coordinates menu visibility.
Copy snippet
<Menu open={isOpen} onOpenChange={(detail) => isOpen = detail.open} items={menuItems}><svelte:fragment slot="trigger">Open menu</svelte:fragment></Menu>Verification
Proofs stay visible in the docs so the system shows what it can guarantee, not just what it can render.
size=sm
size=md
size=lg
size=sm
size=md
size=lg