Navigation Core Stable

ContextMenu

A menu that opens at the pointer on right-click, sharing DropdownMenu's item, submenu and keyboard behaviour but anchored to a virtual point instead of a trigger element.

Preview

Installation

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

Usage

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

<ContextMenu />

Examples

Basic Usage

With Submenu

A nested submenu inside a context menu, using the same Sub primitives as DropdownMenu.

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 pointer to place the menu on. Flips when it would overflow
align "start" | "center" | "end""start"Alignment along the pointer's cross axis
offset number2Gap in pixels between the pointer and the menu
loop booleantrueWhether arrow-key navigation wraps at the ends

Slots

SlotDescription
childrenThe ContextMenuTrigger and ContextMenuContent