Installation
Barrel
import { DropdownMenu } from 'kumo-svelte'; Granular
import { DropdownMenu } from 'kumo-svelte/components/dropdown-menu';Usage
<script> import { DropdownMenu, Button } from "kumo-svelte";</script><DropdownMenu> <DropdownMenu.Trigger> {#snippet child({ props })} <Button {...props}>Menu</Button> {/snippet} </DropdownMenu.Trigger> <DropdownMenu.Content> <DropdownMenu.Item onSelect={() => console.log("edit")}> Edit </DropdownMenu.Item> <DropdownMenu.Item onSelect={() => console.log("duplicate")}> Duplicate </DropdownMenu.Item> <DropdownMenu.Separator /> <DropdownMenu.Item variant="danger" onSelect={() => console.log("delete")} > Delete </DropdownMenu.Item> </DropdownMenu.Content></DropdownMenu>Examples
Basic Dropdown
Inset Items
Use inset on items without an icon to align their text with items that have one.
Handling Item Clicks
Use onSelect on DropdownMenu.Item to handle actions. Each item receives a standard menu select event handler.
Checkbox Items
Use DropdownMenu.CheckboxItem for toggleable options that can be
independently checked or unchecked.
Nested Menu with Radio Selection
Use DropdownMenu.Sub, DropdownMenu.SubTrigger, and DropdownMenu.SubContent to create nested submenus. For single-selection
lists like language or timezone, use DropdownMenu.RadioGroup and DropdownMenu.RadioItem.
Custom Trigger with Avatar
Use the child snippet to customize the trigger element while passing children
to render inside it. This is useful when you need a non-button trigger (like
an avatar) wrapped in an accessible button element.
Navigation Links
Use DropdownMenu.LinkItem for menu items that navigate to a URL.
This renders a semantic <a> element with full control over link attributes like target and rel.
API Reference
DropdownMenu
Root component that manages the dropdown state.
| Prop | Type | Default | Description |
|---|---|---|---|
| children | Snippet | - | Child snippet rendered by the component. |
| open | boolean | false | Controlled open state. |
| onOpenChange | (open: boolean) => void | - | Called when open state changes. |
DropdownMenu.Trigger
Button that opens the dropdown when clicked.
| Prop | Type | Default | Description |
|---|---|---|---|
| child | Snippet<[{ props: Record<string, unknown> }]> | - | child prop. |
| type | 'button' | 'submit' | 'reset' | "button" | Element or semantic type. |
DropdownMenu.Item
Individual menu item for actions.
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | - | Deprecated destination URL for legacy link items. |
| icon | Component | - | Icon rendered by the component. |
| variant | 'default' | 'danger' | "default" | Visual variant. |
| selected | boolean | false | Shows a trailing selected check indicator. |
| inset | boolean | false | Indents the item content. |
| disabled | boolean | - | Disables the component. |
DropdownMenu.LinkItem
A menu item that navigates to a URL. Renders a semantic <a> element. Use this instead of Item for navigation links.
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | - | Deprecated destination URL for legacy link items. |
| icon | Component | - | Icon rendered by the component. |
| variant | 'default' | 'danger' | "default" | Visual variant. |
| selected | boolean | false | Shows a trailing selected check indicator. |
| inset | boolean | false | Indents the item content. |
| disabled | boolean | - | Disables the component. |
DropdownMenu.CheckboxItem
A menu item that can be toggled on or off. Use for independent boolean options.
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | false | Checked state. |
| onCheckedChange | (checked: boolean) => void | - | Called when checked changes. |
DropdownMenu.Sub
Root component for a nested submenu. Wrap SubTrigger and SubContent inside this.
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | false | Controlled open state. |
| onOpenChange | (open: boolean) => void | - | Called when open state changes. |
DropdownMenu.SubTrigger
Menu item that opens a nested submenu when hovered or clicked. Displays a caret icon automatically.
| Prop | Type | Default | Description |
|---|---|---|---|
| icon | Component | - | Icon rendered by the component. |
| inset | boolean | false | Indents the item content. |
DropdownMenu.SubContent
Container for submenu items. Positioned relative to the SubTrigger.
| Prop | Type | Default | Description |
|---|---|---|---|
| sideOffset | number | 8 | Distance from the anchor. |
| side | 'top' | 'right' | 'bottom' | 'left' | - | Preferred floating side. |
| align | 'start' | 'center' | 'end' | - | Floating alignment. |
| container | HTMLElement | string | document.body | Portal container for custom roots or Shadow DOM. |
DropdownMenu.Separator
A visual divider between menu items.
| Prop | Type | Default | Description |
|---|---|---|---|
| No component-specific props. Accepts standard HTML attributes. | |||
DropdownMenu.RadioGroup
Groups radio items for single-selection behavior. Only one item can be selected at a time.
| Prop | Type | Default | Description |
|---|---|---|---|
| No component-specific props. Accepts standard HTML attributes. | |||
DropdownMenu.RadioItem
A menu item that works like a radio button. Must be used inside a RadioGroup.
| Prop | Type | Default | Description |
|---|---|---|---|
| value * | string | - | Controlled value. |
| icon | Component | - | Icon rendered by the component. |
| inset | boolean | false | Indents the item content. |
DropdownMenu.RadioItemIndicator
Shows the selected state for a RadioItem. Displays a checkmark by default.
| Prop | Type | Default | Description |
|---|---|---|---|
| No component-specific props. Accepts standard HTML attributes. | |||