Context Menu
A context menu component that appears on right-click, providing additional actions and nested submenus with keyboard shortcuts.
Import
import ContextMenu from "$lib/components/ContextMenu.svelte"; Basic Example
Right click me
Submenu Example
Right click me
Properties
Name
Type
Description
items
Type
array
Default: []
Array of menu items with optional icons, keyboard shortcuts, and submenus.
triggerClass
Type
string
Default: ""
Additional classes for the trigger element.
contentClass
Type
string
Default: "z-50 w-full max-w-[229px] rounded-xl border border-muted bg-background px-1 py-1.5 shadow-popover outline-none"
Classes for the content container.
itemClass
Type
string
Default: "flex h-10 select-none items-center rounded-button py-3 pl-3 pr-1.5 text-sm font-medium outline-none !ring-0 !ring-transparent data-[highlighted]:bg-muted"
Classes for menu items.
separatorClass
Type
string
Default: "-mx-1 my-1 block h-px bg-muted"
Classes for the separator element.
subContentClass
Type
string
Default: "z-50 w-full max-w-[209px] select-none rounded-xl border border-muted bg-background px-1 py-1.5 shadow-popover outline-none"
Classes for submenu content.