# Rokkit Menu Component > Data-driven dropdown menu with keyboard navigation, grouping, and custom snippets. The Menu component renders a trigger button that opens a dropdown list of selectable options. Supports grouped options, shortcut display, custom item snippets, and named snippet slots per item. ## Quick Start ```svelte console.log(v)} /> ``` ## Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `options` | `MenuItem[]` | `[]` | Menu items array | | `fields` | `MenuFields` | defaults | Field mapping | | `label` | `string` | `'Menu'` | Trigger button label | | `icon` | `string` | — | Trigger button icon class | | `showArrow` | `boolean` | `true` | Show dropdown arrow on trigger | | `size` | `'sm'|'md'|'lg'` | `'md'` | Size variant | | `align` | `'left'|'right'|'start'|'end'` | `'left'` | Dropdown alignment | | `direction` | `'up'|'down'` | `'down'` | Dropdown slide direction | | `disabled` | `boolean` | `false` | Disable the menu | | `icons` | `MenuStateIcons` | — | Override state icons | | `class` | `string` | `''` | Additional CSS classes | ## Field Mapping | Field | Default | Description | |-------|---------|-------------| | `value` | `'value'` | Value emitted on selection | | `text` | `'text'` | Display label | | `icon` | `'icon'` | Icon class name | | `description` | `'description'` | Secondary/subtitle text | | `shortcut` | `'shortcut'` | Keyboard shortcut display | | `label` | `'label'` | Aria-label override | | `disabled` | `'disabled'` | Disabled state | | `children` | `'children'` | Nested group items | | `snippet` | `'snippet'` | Named snippet for custom rendering | ## Callbacks | Callback | Signature | Description | |----------|-----------|-------------| | `onselect` | `(value, item) => void` | Item selected | ## Grouped Options Use the `children` field to create groups: ```svelte ``` ## Custom Item Snippet ```svelte {#snippet item(data, fields, handlers)} {/snippet} ``` ## Named Snippets per Item Use the `snippet` field to assign different renderers to individual items: ```svelte {#snippet divider(data, fields, handlers)}
{/snippet} {#snippet danger(data, fields, handlers)} {/snippet}
``` ## Custom Group Label ```svelte {#snippet groupLabel(data, fields)}
{data.text}
{/snippet}
``` ## Keyboard Navigation | Key | Action | |-----|--------| | `Enter/Space` | Open menu | | `ArrowDown/Up` | Navigate items | | `Enter` | Select focused item | | `Escape` | Close menu | | `Home/End` | First/last item | ## Data Attributes | Attribute | Description | |-----------|-------------| | `data-menu` | Root element | | `data-menu-trigger` | Trigger button | | `data-menu-dropdown` | Dropdown container | | `data-menu-item` | Individual item | | `data-menu-group` | Group container | | `data-menu-group-label` | Group header | | `data-open` | Open state | ## Import ```javascript import { Menu } from '@rokkit/ui' ``` ## TypeScript Types ```typescript interface MenuProps { options?: MenuItem[] fields?: MenuFields label?: string icon?: string showArrow?: boolean size?: 'sm' | 'md' | 'lg' align?: 'left' | 'right' | 'start' | 'end' direction?: 'up' | 'down' disabled?: boolean icons?: MenuStateIcons class?: string onselect?: (value: unknown, item: MenuItem) => void item?: Snippet<[MenuItem, MenuFields, MenuItemHandlers]> groupLabel?: Snippet<[MenuItem, MenuFields]> } interface MenuStateIcons { opened?: string // open arrow icon closed?: string // closed arrow icon } ``` ## Related Components - [Select](/llms/components/select.txt) — form-style dropdown for value selection - [Toolbar](/llms/components/toolbar.txt) — horizontal action bar - [FloatingActions](/llms/components/floating-action.txt) — FAB action menu