Navigation
Dropdown Menu
A floating action menu built on Bits UI with items, labels and separators.
<script>
import { DropdownMenu, DropdownMenuItem, DropdownMenuSeparator, Button } from "@codeatlasdev/ui";
</script>
<DropdownMenu>
{#snippet triggerChild(props)}<Button {...props}>Open menu</Button>{/snippet}
<DropdownMenuItem onclick={edit}>{#snippet children()}Edit{/snippet}</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive" onclick={remove}>{#snippet children()}Delete{/snippet}</DropdownMenuItem>
</DropdownMenu>
Keyboard support comes from Bits UI: Enter or Space opens the menu, arrows move, Escape closes and focus returns to the trigger. Pass an interactive trigger (Button, IconButton) through triggerChild and spread the received props on it. Use trigger only for non-interactive content such as text or an icon.
Default
A button trigger with a label, items, a separator and a destructive item.
Code
Icon trigger
An IconButton trigger. IconButton needs an aria-label.
Code
DropdownMenu
| Prop | Type | Default | Description |
|---|---|---|---|
triggerChild | Snippet<[Record<string, unknown>]> | – | Interactive trigger. Receives the trigger props to spread onto your Button or IconButton. |
trigger | Snippet | – | Non-interactive trigger content (text, icon), wrapped in the menu's own button. |
children | Snippet | – | Menu content: items, labels and separators. |
side | 'top' | 'right' | 'bottom' | 'left' | 'bottom' | Preferred side of the trigger. |
align | 'start' | 'center' | 'end' | 'start' | Alignment against the trigger. |
sideOffset | number | 6 | Distance from the trigger in pixels. |
class | string | '' | Extra CSS classes on the content. |
DropdownMenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
onclick | () => void | – | Called when the item is selected. |
variant | 'default' | 'destructive' | 'default' | destructive colors the item with the error token. |
disabled | boolean | false | Prevents selection. |
children | Snippet | – | Item content, usually an icon and a label. |
class | string | '' | Extra CSS classes. |