Navigation Core Stable

DropdownMenu

A menu of actions or options that opens from a trigger button, with full keyboard navigation, submenus and real DOM focus on every item.

Preview

Installation

pnpm add fancy-ui-svelte
import { DropdownMenu } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { DropdownMenu } from 'fancy-ui-svelte';
</script>

<DropdownMenu />

Examples

Basic Usage

With Shortcuts

Display-only keyboard shortcuts rendered as trailing kbd tags.

Destructive Item

A destructive action set apart with the destructive variant.

With Submenu

A nested submenu that opens on hover, click or ArrowRight.

Disabled Items

Disabled rows are skipped by keyboard navigation and inert to click.

Props

PropTypeDefaultDescription
open booleanfalseWhether the menu is open. Bindable
onOpenChange (open: boolean) => void-Called whenever the menu opens or closes, however it happened
side "top" | "bottom" | "left" | "right""bottom"Side of the trigger to place the menu on. Flips when it would overflow
align "start" | "center" | "end""start"Alignment along the trigger's cross axis
offset number4Gap in pixels between the trigger and the menu
loop booleantrueWhether arrow-key navigation wraps at the ends
sound booleanfalsePlays open and close on the trigger and submenus, and select on an item — one cue per interaction — once the user has enabled sound

Slots

SlotDescription
childrenThe DropdownMenuTrigger and DropdownMenuContent