Skip to content
Panels and menusInteractive playground

Menu

A dropdown action menu or menu bar.

Preparing the playground…
Text and Markdown example
Menu · Example
1<Menu><MenuTrigger asChild><Button variant="outline">Actions</Button></MenuTrigger><MenuContent><MenuItem onSelect={() => window.alert("New demo project")}>New project</MenuItem><MenuSeparator /><MenuItem disabled>Export (unavailable)</MenuItem></MenuContent></Menu>
Read documentation in Markdown

How to use it

Connect onSelect on action items. Combine separators, groups, checkbox options and submenus.

Import

React / Next.js
1import { Menu, MenuTrigger, MenuContent, MenuItem, MenuGroup, MenuLabel, MenuSeparator, MenuCheckboxItem, MenuRadioGroup, MenuRadioItem, MenuSub, MenuSubTrigger, MenuSubContent, MenuShortcut, MenuPortal, MenuDropdown } from "@kivora/nextjs";

Interactive examples run inside a component with "use client". The playground's Copy button includes the imports needed for the current example.

API reference 0.2.0

Types from the installed published version, including component properties and common HTML attributes. “Optional” does not imply a default value; omitting a property lets the component decide.

PropertyTypeDescription
variantRequired"dropdown" | "bar"Visual variant. Use a value supported by this component.
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultOpenbooleanWhether it starts open in uncontrolled mode.
defaultValuestringInitial value when the component manages its own state.
dir"ltr" | "rtl"Interface reading direction.
idstringElement identifier; associates labels and descriptions.
loopbooleanConfigures loop. The type describes the supported values and structure.
modalbooleanConfigures modal. The type describes the supported values and structure.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onOpenChange((open: boolean) => void)Receives the new open state.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
onValueChange((value: string) => void)Receives the value after an interaction.
openbooleanControlled open state.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
valuestringControlled value. Update it from the change callback.

Subcomponents and composition

Review each component's properties and published declaration. Native and accessibility attributes are inherited from the element specified by its type.

Menu23 properties
Menu · TypeScript
1Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLDivElement>>
MenuTrigger18 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
namestringName used to identify the control in forms.
onChangeChangeEventHandler<HTMLButtonElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLButtonElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLButtonElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
type"button" | "submit" | "reset"Operation type or mode; values depend on the component.
valuestring | number | readonly string[]Controlled value. Update it from the change callback.
MenuTrigger · TypeScript
1MenuTrigger: React.ForwardRefExoticComponent<Omit<Omit<DropdownPrimitive.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>
MenuContent32 properties
PropertyTypeDescription
align"center" | "start" | "end"Content alignment.
alignOffsetnumberOffset from the chosen alignment.
aria-labelstringAccessible name of the control.
arrowPaddingnumberConfigures arrowPadding. The type describes the supported values and structure.
asChildbooleanApply props and behavior to a single compatible child element.
avoidCollisionsbooleanConfigures avoidCollisions. The type describes the supported values and structure.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
collisionBoundaryBoundary | Boundary[]Configures collisionBoundary. The type describes the supported values and structure.
collisionPaddingnumber | Partial<Record<"left" | "right" | "top" | "bottom", number>>Configures collisionPadding. The type describes the supported values and structure.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
hideWhenDetachedbooleanConfigures hideWhenDetached. The type describes the supported values and structure.
idstringElement identifier; associates labels and descriptions.
loopbooleanWhether keyboard navigation should loop around
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onCloseAutoFocus((event: Event) => void)Event handler called when auto-focusing on close. Can be prevented.
onEscapeKeyDown((event: KeyboardEvent) => void)Callback for this event. The signature describes its arguments.
onFocusOutside((event: FocusOutsideEvent) => void)Callback for this event. The signature describes its arguments.
onInteractOutside((event: PointerDownOutsideEvent | FocusOutsideEvent) => void)Callback for this event. The signature describes its arguments.
onPointerDownOutside((event: PointerDownOutsideEvent) => void)Callback for this event. The signature describes its arguments.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
side"left" | "right" | "top" | "bottom"Side from which the panel appears.
sideOffsetnumberDistance between the trigger and content.
sticky"partial" | "always"Configures sticky. The type describes the supported values and structure.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
updatePositionStrategy"always" | "optimized"Configures updatePositionStrategy. The type describes the supported values and structure.
MenuContent · TypeScript
1MenuContent: React.ForwardRefExoticComponent<MenuContentProps & React.RefAttributes<HTMLDivElement>>
MenuItem18 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
insetbooleanConfigures inset. The type describes the supported values and structure.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSelect((event: Event) => void)Action or selection made by the user.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
textValuestringConfigures textValue. The type describes the supported values and structure.
titlestringTitle or supplementary information.
MenuItem · TypeScript
1MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLDivElement>>
MenuGroup14 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
MenuGroup · TypeScript
1MenuGroup: React.ForwardRefExoticComponent<Omit<DropdownPrimitive.DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>
MenuLabel15 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
insetbooleanConfigures inset. The type describes the supported values and structure.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
MenuLabel · TypeScript
1MenuLabel: React.ForwardRefExoticComponent<MenuLabelProps & React.RefAttributes<HTMLDivElement>>
MenuSeparator14 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
MenuSeparator · TypeScript
1MenuSeparator: React.ForwardRefExoticComponent<MenuSeparatorProps & React.RefAttributes<HTMLDivElement>>
MenuCheckboxItem19 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
checkedCheckedStateControlled selection state.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onCheckedChange((checked: boolean) => void)Receives the new selection state.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSelect((event: Event) => void)Action or selection made by the user.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
textValuestringConfigures textValue. The type describes the supported values and structure.
titlestringTitle or supplementary information.
MenuCheckboxItem · TypeScript
1MenuCheckboxItem: React.ForwardRefExoticComponent<MenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>
MenuRadioGroup16 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
onValueChange((value: string) => void)Receives the value after an interaction.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
valuestringControlled value. Update it from the change callback.
MenuRadioGroup · TypeScript
1MenuRadioGroup: typeof RoutedRadioGroup
MenuRadioItem18 properties
PropertyTypeDescription
valueRequiredstringControlled value. Update it from the change callback.
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSelect((event: Event) => void)Action or selection made by the user.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
textValuestringConfigures textValue. The type describes the supported values and structure.
titlestringTitle or supplementary information.
MenuRadioItem · TypeScript
1MenuRadioItem: React.ForwardRefExoticComponent<MenuRadioItemProps & React.RefAttributes<HTMLDivElement>>
MenuSub4 properties
PropertyTypeDescription
childrenReactNodeContent or child elements of the component.
defaultOpenbooleanWhether it starts open in uncontrolled mode.
onOpenChange((open: boolean) => void)Receives the new open state.
openbooleanControlled open state.
MenuSub · TypeScript
1MenuSub: typeof RoutedSub
MenuSubTrigger17 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
insetbooleanConfigures inset. The type describes the supported values and structure.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
textValuestringConfigures textValue. The type describes the supported values and structure.
titlestringTitle or supplementary information.
MenuSubTrigger · TypeScript
1MenuSubTrigger: React.ForwardRefExoticComponent<MenuSubTriggerProps & React.RefAttributes<HTMLDivElement>>
MenuSubContent30 properties
PropertyTypeDescription
align"start" | "end"Content alignment.
alignOffsetnumberOffset from the chosen alignment.
aria-labelstringAccessible name of the control.
arrowPaddingnumberConfigures arrowPadding. The type describes the supported values and structure.
asChildbooleanApply props and behavior to a single compatible child element.
avoidCollisionsbooleanConfigures avoidCollisions. The type describes the supported values and structure.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
collisionBoundaryBoundary | Boundary[]Configures collisionBoundary. The type describes the supported values and structure.
collisionPaddingnumber | Partial<Record<"left" | "right" | "top" | "bottom", number>>Configures collisionPadding. The type describes the supported values and structure.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
hideWhenDetachedbooleanConfigures hideWhenDetached. The type describes the supported values and structure.
idstringElement identifier; associates labels and descriptions.
loopbooleanWhether keyboard navigation should loop around
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onEscapeKeyDown((event: KeyboardEvent) => void)Callback for this event. The signature describes its arguments.
onFocusOutside((event: FocusOutsideEvent) => void)Callback for this event. The signature describes its arguments.
onInteractOutside((event: PointerDownOutsideEvent | FocusOutsideEvent) => void)Callback for this event. The signature describes its arguments.
onPointerDownOutside((event: PointerDownOutsideEvent) => void)Callback for this event. The signature describes its arguments.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
sideOffsetnumberDistance between the trigger and content.
sticky"partial" | "always"Configures sticky. The type describes the supported values and structure.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
updatePositionStrategy"always" | "optimized"Configures updatePositionStrategy. The type describes the supported values and structure.
MenuSubContent · TypeScript
1MenuSubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>
MenuShortcut13 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLSpanElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLSpanElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLSpanElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
MenuShortcut · TypeScript
1MenuShortcut: { 2 ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element; 3 displayName: string; 4}
MenuPortal3 properties
PropertyTypeDescription
childrenReactNodeContent or child elements of the component.
containerElement | DocumentFragment | nullSpecify a container element to portal the content into.
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
MenuPortal · TypeScript
1MenuPortal: typeof RoutedPortal
MenuDropdown3 properties
PropertyTypeDescription
__scopeMenubarScopeConfigures __scopeMenubar. The type describes the supported values and structure.
childrenReactNodeContent or child elements of the component.
valuestringControlled value. Update it from the change callback.
MenuDropdown · TypeScript
1MenuDropdown: React.FC<React.ComponentPropsWithoutRef<typeof BarPrimitive.Menu>>
API generated from @kivora/nextjs 0.2.0View package