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>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.
| Property | Type | Description |
|---|---|---|
variantRequired | "dropdown" | "bar" | Visual variant. Use a value supported by this component. |
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultOpen | boolean | Whether it starts open in uncontrolled mode. |
defaultValue | string | Initial value when the component manages its own state. |
dir | "ltr" | "rtl" | Interface reading direction. |
id | string | Element identifier; associates labels and descriptions. |
loop | boolean | Configures loop. The type describes the supported values and structure. |
modal | boolean | Configures modal. The type describes the supported values and structure. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onOpenChange | ((open: boolean) => void) | Receives the new open state. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
onValueChange | ((value: string) => void) | Receives the value after an interaction. |
open | boolean | Controlled open state. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
value | string | Controlled 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
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
disabled | boolean | Disable interaction with the control. |
id | string | Element identifier; associates labels and descriptions. |
name | string | Name used to identify the control in forms. |
onChange | ChangeEventHandler<HTMLButtonElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLButtonElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLButtonElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
type | "button" | "submit" | "reset" | Operation type or mode; values depend on the component. |
value | string | 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
| Property | Type | Description |
|---|---|---|
align | "center" | "start" | "end" | Content alignment. |
alignOffset | number | Offset from the chosen alignment. |
aria-label | string | Accessible name of the control. |
arrowPadding | number | Configures arrowPadding. The type describes the supported values and structure. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
avoidCollisions | boolean | Configures avoidCollisions. The type describes the supported values and structure. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
collisionBoundary | Boundary | Boundary[] | Configures collisionBoundary. The type describes the supported values and structure. |
collisionPadding | number | Partial<Record<"left" | "right" | "top" | "bottom", number>> | Configures collisionPadding. The type describes the supported values and structure. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
forceMount | true | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. |
hideWhenDetached | boolean | Configures hideWhenDetached. The type describes the supported values and structure. |
id | string | Element identifier; associates labels and descriptions. |
loop | boolean | Whether keyboard navigation should loop around |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<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. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
side | "left" | "right" | "top" | "bottom" | Side from which the panel appears. |
sideOffset | number | Distance between the trigger and content. |
sticky | "partial" | "always" | Configures sticky. The type describes the supported values and structure. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title 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
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
disabled | boolean | Disable interaction with the control. |
id | string | Element identifier; associates labels and descriptions. |
inset | boolean | Configures inset. The type describes the supported values and structure. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSelect | ((event: Event) => void) | Action or selection made by the user. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
textValue | string | Configures textValue. The type describes the supported values and structure. |
title | string | Title or supplementary information. |
MenuItem · TypeScript
1MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLDivElement>>MenuGroup14 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
MenuGroup · TypeScript
1MenuGroup: React.ForwardRefExoticComponent<Omit<DropdownPrimitive.DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>MenuLabel15 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
inset | boolean | Configures inset. The type describes the supported values and structure. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
MenuLabel · TypeScript
1MenuLabel: React.ForwardRefExoticComponent<MenuLabelProps & React.RefAttributes<HTMLDivElement>>MenuSeparator14 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
MenuSeparator · TypeScript
1MenuSeparator: React.ForwardRefExoticComponent<MenuSeparatorProps & React.RefAttributes<HTMLDivElement>>MenuCheckboxItem19 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
checked | CheckedState | Controlled selection state. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
disabled | boolean | Disable interaction with the control. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<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. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSelect | ((event: Event) => void) | Action or selection made by the user. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
textValue | string | Configures textValue. The type describes the supported values and structure. |
title | string | Title or supplementary information. |
MenuCheckboxItem · TypeScript
1MenuCheckboxItem: React.ForwardRefExoticComponent<MenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>MenuRadioGroup16 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
onValueChange | ((value: string) => void) | Receives the value after an interaction. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
value | string | Controlled value. Update it from the change callback. |
MenuRadioGroup · TypeScript
1MenuRadioGroup: typeof RoutedRadioGroupMenuRadioItem18 properties
| Property | Type | Description |
|---|---|---|
valueRequired | string | Controlled value. Update it from the change callback. |
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
disabled | boolean | Disable interaction with the control. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSelect | ((event: Event) => void) | Action or selection made by the user. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
textValue | string | Configures textValue. The type describes the supported values and structure. |
title | string | Title or supplementary information. |
MenuRadioItem · TypeScript
1MenuRadioItem: React.ForwardRefExoticComponent<MenuRadioItemProps & React.RefAttributes<HTMLDivElement>>MenuSub4 properties
| Property | Type | Description |
|---|---|---|
children | ReactNode | Content or child elements of the component. |
defaultOpen | boolean | Whether it starts open in uncontrolled mode. |
onOpenChange | ((open: boolean) => void) | Receives the new open state. |
open | boolean | Controlled open state. |
MenuSub · TypeScript
1MenuSub: typeof RoutedSubMenuSubTrigger17 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
disabled | boolean | Disable interaction with the control. |
id | string | Element identifier; associates labels and descriptions. |
inset | boolean | Configures inset. The type describes the supported values and structure. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
textValue | string | Configures textValue. The type describes the supported values and structure. |
title | string | Title or supplementary information. |
MenuSubTrigger · TypeScript
1MenuSubTrigger: React.ForwardRefExoticComponent<MenuSubTriggerProps & React.RefAttributes<HTMLDivElement>>MenuSubContent30 properties
| Property | Type | Description |
|---|---|---|
align | "start" | "end" | Content alignment. |
alignOffset | number | Offset from the chosen alignment. |
aria-label | string | Accessible name of the control. |
arrowPadding | number | Configures arrowPadding. The type describes the supported values and structure. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
avoidCollisions | boolean | Configures avoidCollisions. The type describes the supported values and structure. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
collisionBoundary | Boundary | Boundary[] | Configures collisionBoundary. The type describes the supported values and structure. |
collisionPadding | number | Partial<Record<"left" | "right" | "top" | "bottom", number>> | Configures collisionPadding. The type describes the supported values and structure. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
forceMount | true | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. |
hideWhenDetached | boolean | Configures hideWhenDetached. The type describes the supported values and structure. |
id | string | Element identifier; associates labels and descriptions. |
loop | boolean | Whether keyboard navigation should loop around |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<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. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
sideOffset | number | Distance between the trigger and content. |
sticky | "partial" | "always" | Configures sticky. The type describes the supported values and structure. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title 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
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLSpanElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLSpanElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLSpanElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
MenuShortcut · TypeScript
1MenuShortcut: {
2 ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
3 displayName: string;
4}MenuPortal3 properties
| Property | Type | Description |
|---|---|---|
children | ReactNode | Content or child elements of the component. |
container | Element | DocumentFragment | null | Specify a container element to portal the content into. |
forceMount | true | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. |
MenuPortal · TypeScript
1MenuPortal: typeof RoutedPortalMenuDropdown3 properties
| Property | Type | Description |
|---|---|---|
__scopeMenubar | Scope | Configures __scopeMenubar. The type describes the supported values and structure. |
children | ReactNode | Content or child elements of the component. |
value | string | Controlled 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