1. framework components
  2. menu

Menu

Accessible dropdown and context menus for actions and navigation.

Breaking convention in Skeleton, this component is provided “headless”. Meaning no default styles are applied out of the box. This ensures you retain full control of all styling for maximum flexibility.

Grouped Items

Use ItemGroup and ItemGroupLabel to organize menu items into logical sections.

Option Items

Use OptionItem with type="checkbox" or type="radio" to create selectable menu items.

Context Menu

Use ContextTrigger instead of Trigger to open the menu on right-click.

Anatomy

Here’s an overview of how the Menu component is structured in code:

tsx
import { Menu, Portal } from '@skeletonlabs/skeleton-react';

export default function Anatomy() {
	return (
		<Menu>
			<Menu.Trigger />
			{/* or <Menu.ContextTrigger /> for right-click */}
			<Portal>
				<Menu.Positioner>
					<Menu.Content>
						{/* Simple items */}
						<Menu.Item value="..." />
						<Menu.Separator />
						
						{/* Grouped items */}
						<Menu.ItemGroup>
							<Menu.ItemGroupLabel />
							<Menu.Item value="..." />
						</Menu.ItemGroup>
						
						{/* Option items (checkbox/radio) */}
						<Menu.OptionItem type="checkbox" name="..." value="..." />
						
						{/* Optional arrow */}
						<Menu.Arrow>
							<Menu.ArrowTip />
						</Menu.Arrow>
					</Menu.Content>
				</Menu.Positioner>
			</Portal>
		</Menu>
	);
}

API Reference

Root

PropDefaultType
idsPartial<{ trigger: string; contextTrigger: string; content: string; groupLabel: (id: string) => string; group: (id: string) => string; positioner: string; arrow: string; }> | undefined

The ids of the elements in the menu. Useful for composition.

defaultHighlightedValuestring | null | undefined

The initial highlighted value of the menu item when rendered. Use when you don't need to control the highlighted value of the menu item.

highlightedValuestring | null | undefined

The controlled highlighted value of the menu item.

onHighlightChange((details: HighlightChangeDetails) => void) | undefined

Function called when the highlighted menu item changes.

onSelect((details: SelectionDetails) => void) | undefined

Function called when a menu item is selected.

anchorPointPoint | null | undefined

The positioning point for the menu. Can be set by the context menu trigger or the button trigger.

loopFocusfalseboolean | undefined

Whether to loop the keyboard navigation.

positioningPositioningOptions | undefined

The options used to dynamically position the menu

closeOnSelecttrueboolean | undefined

Whether to close the menu when an option is selected

aria-labelstring | undefined

The accessibility label for the menu

openboolean | undefined

The controlled open state of the menu

onOpenChange((details: OpenChangeDetails) => void) | undefined

Function called when the menu opens or closes

defaultOpenboolean | undefined

The initial open state of the menu when rendered. Use when you don't need to control the open state of the menu.

typeaheadtrueboolean | undefined

Whether the pressing printable characters should trigger typeahead navigation

compositetrueboolean | undefined

Whether the menu is a composed with other composite widgets like a combobox or tabs

navigate((details: NavigateDetails) => void) | null | undefined

Function to navigate to the selected item if it's an anchor element

dir"ltr""ltr" | "rtl" | undefined

The document's text/writing direction.

getRootNode(() => ShadowRoot | Node | Document) | undefined

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

onEscapeKeyDown((event: KeyboardEvent) => void) | undefined

Function called when the escape key is pressed

onRequestDismiss((event: LayerDismissEvent) => void) | undefined

Function called when this layer is closed due to a parent layer being closed

onPointerDownOutside((event: PointerDownOutsideEvent) => void) | undefined

Function called when the pointer is pressed down outside the component

onFocusOutside((event: FocusOutsideEvent) => void) | undefined

Function called when the focus is moved outside the component

onInteractOutside((event: InteractOutsideEvent) => void) | undefined

Function called when an interaction happens outside the component

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Provider

PropDefaultType
valueMenuApi<PropTypes> & { service: MenuService; }

childrenReactNode

Context

PropDefaultType
children(menu: MenuApi<PropTypes> & { service: MenuService; }) => ReactNode

Trigger

PropDefaultType
element((attributes: HTMLAttributes<"button">) => Element) | undefined

Render the element yourself

ContextTrigger

PropDefaultType
element((attributes: HTMLAttributes<"button">) => Element) | undefined

Render the element yourself

Positioner

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Content

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Arrow

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

ArrowTip

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Item

PropDefaultType
valuestring

The unique value of the menu item option.

disabledboolean | undefined

Whether the menu item is disabled

valueTextstring | undefined

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

closeOnSelectboolean | undefined

Whether the menu should be closed when the option is selected.

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

OptionItem

PropDefaultType
checkedboolean

Whether the option is checked

type"radio" | "checkbox"

Whether the option is a radio or a checkbox

valuestring

The value of the option

onCheckedChange((checked: boolean) => void) | undefined

Function called when the option state is changed

disabledboolean | undefined

Whether the menu item is disabled

valueTextstring | undefined

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

closeOnSelectboolean | undefined

Whether the menu should be closed when the option is selected.

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

TriggerItem

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

ItemGroup

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

ItemGroupLabel

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Separator

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

View page on GitHub