Skip to content

Menu

A list of actions in a dropdown, enhanced with keyboard navigation.

API Reference

Installation

pnpm dlx shadcn@latest add @frontal-labs/menu

Usage

import {
  Menu,
  MenuCheckboxItem,
  MenuGroup,
  MenuGroupLabel,
  MenuItem,
  MenuLinkItem,
  MenuPopup,
  MenuRadioGroup,
  MenuRadioItem,
  MenuSeparator,
  MenuSub,
  MenuSubPopup,
  MenuSubTrigger,
  MenuTrigger,
} from "@/components/ui/menu";
<Menu>
  <MenuTrigger>Open</MenuTrigger>
  <MenuPopup align="start" sideOffset={4}>
    <MenuItem>Profile</MenuItem>
    <MenuSeparator />
 
    <MenuGroup>
      <MenuGroupLabel>Playback</MenuGroupLabel>
      <MenuItem>Play</MenuItem>
      <MenuItem>Pause</MenuItem>
    </MenuGroup>
 
    <MenuSeparator />
 
    <MenuCheckboxItem>Shuffle</MenuCheckboxItem>
    <MenuCheckboxItem>Repeat</MenuCheckboxItem>
    <MenuCheckboxItem variant="switch">Auto save</MenuCheckboxItem>
 
    <MenuSeparator />
 
    <MenuGroup>
      <MenuGroupLabel>Sort by</MenuGroupLabel>
      <MenuRadioGroup>
        <MenuRadioItem>Artist</MenuRadioItem>
        <MenuRadioItem>Album</MenuRadioItem>
        <MenuRadioItem>Title</MenuRadioItem>
      </MenuRadioGroup>
    </MenuGroup>
 
    <MenuSeparator />
 
    <MenuSub>
      <MenuSubTrigger>Add to playlist</MenuSubTrigger>
      <MenuSubPopup>
        <MenuItem>Jazz</MenuItem>
        <MenuItem>Rock</MenuItem>
      </MenuSubPopup>
    </MenuSub>
  </MenuPopup>
</Menu>

API Reference

Root component. Alias for Menu.Root from Base UI.

Trigger button that opens the menu. Alias for Menu.Trigger from Base UI.

Popup container that displays the menu content. The surface is elevated with shadow-menu and surface-ring.

About dark: the menu renders with the dark palette by default. Pass dark={false} when it should follow the ambient theme instead — next-themes sets dark on <html> and the portal lands in document.body, inside it, so the menu can pick up the ambient theme once dark is turned off. For a menu opened from a .dark region scoped mid-page, which a portal does escape, portalProps.container is usually the better tool: it renders into the scoped node and keeps inheritance intact in both directions without needing this prop.

Groups related menu items. Alias for Menu.Group from Base UI.

Individual menu item.

Using inset: When mixing items with and without icons, use inset on icon-less items to maintain alignment:

<MenuItem><PencilIcon /> Edit</MenuItem>
<MenuItem><TrashIcon /> Delete</MenuItem>
<MenuItem inset>Profile</MenuItem>  {/* Aligns with icon items above */}

Link menu item for navigation. LinkItem renders a native <a> when you pass href. Styled like MenuItem.

If you were using MenuItem render={<Link href="..." />}, migrate to MenuLinkItem but keep render — do not replace it with href alone when using a router Link.

<MenuLinkItem render={<Link href="/docs" />}>Docs</MenuLinkItem>

Use href only for plain anchor links:

<MenuLinkItem href="/docs">Docs</MenuLinkItem>

Checkbox menu item.

Groups radio menu items. Alias for Menu.RadioGroup from Base UI.

Radio menu item. Styled wrapper for Menu.RadioItem from Base UI.

Label for a menu group.

Visual separator between menu items. Styled wrapper for Menu.Separator from Base UI.

Displays keyboard shortcut text. Custom component (not a Base UI wrapper).

Submenu container. Alias for Menu.SubmenuRoot from Base UI.

Trigger for opening a submenu.

Popup for submenu content. Renders through MenuPopup, so it carries the same shadow-menu + surface-ring elevation.

Examples

Open on Hover

With Checkbox

With Switch

MenuCheckboxItem supports a variant="switch" prop that displays a decorative switch indicator instead of a checkmark. This is a purely visual variant - the component remains a checkbox item with the same functionality.

With Radio Group

With Group Label

Nested Menu

Close on Click

Open a Dialog