Component
DropdownMenu
A menu of actions, from an items array or your own snippet.
import { DropdownMenu } from '@loidolt/theme-svelte';
Example
no action selected Grid on · rulers off · by name
Notes
- Shortcut hints are exposed to assistive tech, not
aria-hidden— a shortcut nobody can hear may as well not exist. - For checkbox items, radio items, or submenus, drop to the re-exported
DropdownMenuPrimitive. itemsalso takestype: 'group'(a heading over rows),'checkbox'(a toggle, reported throughonCheckedChange),'radio'(one of many, throughonValueChange) and'sub'(a nested menu) entries. Toggles and choices keep the menu open.shortcutsetsaria-keyshortcutsand shows as the hint. The menu does not bind the key; your app does.destructivestyles an item as danger. Pair it with a confirmation for anything irreversible.
Props
Generated from the component source, so it cannot drift from the implementation.
| Prop | Type | Default | Notes |
|---|---|---|---|
align | Alignment | 'start' | |
children | Snippet | — | Escape hatch: compose the menu body yourself from the re-exported primitives. |
class | string | — | class lands on the portaled Content element. |
groupLabel | string | — | Heading rendered above items, associated with them via a menu group. |
items | MenuEntry<T>[] | [] | Declarative rows: plain items, plus type: 'group' | 'checkbox' | 'radio' | 'sub' entries for headings, toggles, one-of-many choices and nested menus. Ignored when children is provided. |
onCheckedChange | (value: T, checked: boolean) => void | — | A checkbox entry was toggled. Update its checked in your items. |
onOpenChange | (open: boolean) => void | — | |
onSelect | (value: T) => void | — | An action row was chosen. |
onValueChange | (name: string, value: T) => void | — | A radio group's choice changed. Update its value in your items. |
open bindable | boolean | false | |
ref bindable | HTMLElement | null | null | |
side | Placement | 'bottom' | |
sideOffset | number | 6 | |
trigger | Snippet | — | |
triggerChild | Snippet<[TriggerChildProps]> | — | Full control of the trigger element — receives the props Bits needs on it. |
triggerClass | string | 'ldt-button ldt-button--quiet' |
Plus the attributes of Omit<DropdownMenuContentProps, 'children' | 'class' | 'child'>, forwarded to the root element.