Skip to Content
Documentation
Saas UI
Get Pro
Getting started
Components
Overview

Menu

Used to create an accessible dropdown menu

SourceStorybookRecipeArk

Anatomy

import { Menu } from '@saas-ui/react/menu'
<Menu.Root>
  <Menu.Button />
  <Menu.Content>
    <Menu.Item value="item" />
  </Menu.Content>
</Menu.Root>

Examples

Sizes

Use the size prop to control the size of the menu. The default size is md.

Command

Use the MenuItemCommand component to display a command in the menu.

Context menu

Use the MenuContextTrigger component to create a context menu.

Group

Use the MenuItemGroup component to group related menu items.

Here's an example of how to create a submenu.

Pass the asChild prop to the MenuItem component to render a link.

With Radio

Here's an example of how to create a menu with radio.

With Checkbox

Here's an example of how to create a menu with checkbox.

Icon and Command

Compose the menu to include icons and commands.

Placement

Use the positioning.placement prop to control the placement of the menu.

Mixed Layout

Here's an example of how to create a mixed layout of menu items. In this layout, the top horizontal menu includes common menu items.

Props

Root

PropDefaultType
closeOnSelect true
boolean

Whether to close the menu when an option is selected

composite true
boolean

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

lazyMount false
boolean

Whether to enable lazy mounting

loopFocus false
boolean

Whether to loop the keyboard navigation.

skipAnimationOnMount false
boolean

Whether to allow the initial presence animation.

typeahead true
boolean

Whether the pressing printable characters should trigger typeahead navigation

unmountOnExit false
boolean

Whether to unmount on exit.

colorPalette 'gray'
'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'presence' | 'status' | 'sidebar' | 'sidebar.accent' | 'accent' | 'slate'

The color palette of the component

variant 'subtle'
'subtle' | 'solid'

The variant of the component

size 'md'
'sm' | 'md'

The size of the component

anchorPoint
Point

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

aria-label
string

The accessibility label for the menu

defaultHighlightedValue
string

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.

defaultOpen
boolean

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

highlightedValue
string

The controlled highlighted value of the menu item.

id
string

The unique identifier of the machine.

ids
Partial<{ trigger: string contextTrigger: string content: string groupLabel(id: string): string group(id: string): string positioner: string arrow: string }>

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

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

navigate
(details: NavigateDetails) => void

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

onEscapeKeyDown
(event: KeyboardEvent) => void

Function called when the escape key is pressed

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

onFocusOutside
(event: FocusOutsideEvent) => void

Function called when the focus is moved outside the component

onHighlightChange
(details: HighlightChangeDetails) => void

Function called when the highlighted menu item changes.

onInteractOutside
(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the component

onOpenChange
(details: OpenChangeDetails) => void

Function called when the menu opens or closes

onPointerDownOutside
(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the component

onSelect
(details: SelectionDetails) => void

Function called when a menu item is selected.

open
boolean

The controlled open state of the menu

positioning
PositioningOptions

The options used to dynamically position the menu

present
boolean

Whether the node is present (controlled by the user)

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
unstyled
boolean

Whether to remove the component's style.

Item

PropDefaultType
value *
string

The unique value of the menu item option.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
closeOnSelect
boolean

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

disabled
boolean

Whether the menu item is disabled

onSelect
VoidFunction

The function to call when the item is selected

valueText
string

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.

Previous

Input

Next

Number Input