gnome-ui
Components

Context Menu

A contextual menu activated by right click (or long press on touch) to expose relevant actions without leaving the current surface.

Quick Implementation

  1. Wrap the interactive area with ContextMenu.Root.
  2. Use ContextMenu.Trigger as the right-click surface.
  3. Render menu content inside Portal → Positioner → Popup.
  4. Add actions with Item, CheckboxItem, RadioItem, or SubmenuRoot.
  5. Keep visual consistency with theme tokens: bg-card, bg-popover, border-border, text-foreground, text-muted-foreground, bg-accent.
Context Menu component
Right click here to open the context menu
import { ContextMenu } from 'gnome-ui/context-menu';
import { Copy, Trash2 } from 'lucide-react';

export function ContextMenuBasic() {
  return (
    <ContextMenu.Root>
      <ContextMenu.Trigger className="block rounded-lg border border-border bg-background px-5 py-8 text-center text-sm text-muted-foreground hover:bg-accent/50">
        Right click here
      </ContextMenu.Trigger>

      <ContextMenu.Portal>
        <ContextMenu.Positioner sideOffset={8} className="z-50 outline-none">
          <ContextMenu.Popup className="z-50 min-w-[220px] rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-md">
            <ContextMenu.Item className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground">
              <Copy className="size-4 text-muted-foreground" />
              Copy
            </ContextMenu.Item>
            <ContextMenu.Separator className="mx-1 my-1 h-px bg-border" />
            <ContextMenu.Item className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm text-destructive data-[highlighted]:bg-destructive/10 data-[highlighted]:text-destructive">
              <Trash2 className="size-4" />
              Delete
            </ContextMenu.Item>
          </ContextMenu.Popup>
        </ContextMenu.Positioner>
      </ContextMenu.Portal>
    </ContextMenu.Root>
  );
}

Anatomy

import { ContextMenu } from 'gnome-ui/context-menu';

<ContextMenu.Root>
  <ContextMenu.Trigger />
  <ContextMenu.Portal>
    <ContextMenu.Positioner>
      <ContextMenu.Popup>
        <ContextMenu.Item />
      </ContextMenu.Popup>
    </ContextMenu.Positioner>
  </ContextMenu.Portal>
</ContextMenu.Root>

Examples

View Options (checkbox + radio)

Ideal for file-manager style views where you need quick toggles and sorting options.

Context Menu component
Right click to configure view options
import { ContextMenu } from 'gnome-ui/context-menu';
import { Check } from 'lucide-react';

export function ContextMenuViewOptions() {
  return (
    <ContextMenu.Root>
      <ContextMenu.Trigger className="block rounded-lg border border-border bg-background px-5 py-8 text-center text-sm text-muted-foreground hover:bg-accent/50">
        Right click to configure view options
      </ContextMenu.Trigger>

      <ContextMenu.Portal>
        <ContextMenu.Positioner sideOffset={8} className="z-50 outline-none">
          <ContextMenu.Popup className="z-50 min-w-[220px] rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-md">
            <ContextMenu.Group>
              <ContextMenu.GroupLabel className="px-2 py-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
                Visibility
              </ContextMenu.GroupLabel>

              <ContextMenu.CheckboxItem className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground" defaultChecked>
                <ContextMenu.CheckboxItemIndicator className="flex size-4 items-center justify-center">
                  <Check className="size-3.5 text-primary" />
                </ContextMenu.CheckboxItemIndicator>
                Show hidden files
              </ContextMenu.CheckboxItem>
            </ContextMenu.Group>

            <ContextMenu.Separator className="mx-1 my-1 h-px bg-border" />

            <ContextMenu.RadioGroup defaultValue="name">
              <ContextMenu.RadioItem value="name" className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground">
                <ContextMenu.RadioItemIndicator className="flex size-4 items-center justify-center">
                  <div className="size-2 rounded-full bg-primary" />
                </ContextMenu.RadioItemIndicator>
                Name
              </ContextMenu.RadioItem>
            </ContextMenu.RadioGroup>
          </ContextMenu.Popup>
        </ContextMenu.Positioner>
      </ContextMenu.Portal>
    </ContextMenu.Root>
  );
}

Perfect for keeping the main menu clean when secondary actions (like sharing) are needed.

Context Menu component
Right click to open actions with submenu
import { ContextMenu } from 'gnome-ui/context-menu';
import { ChevronRight, Share2 } from 'lucide-react';

export function ContextMenuSubmenu() {
  return (
    <ContextMenu.Root>
      <ContextMenu.Trigger className="block rounded-lg border border-border bg-background px-5 py-8 text-center text-sm text-muted-foreground hover:bg-accent/50">
        Right click to open actions with submenu
      </ContextMenu.Trigger>

      <ContextMenu.Portal>
        <ContextMenu.Positioner sideOffset={8} className="z-50 outline-none">
          <ContextMenu.Popup className="z-50 min-w-[220px] rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-md">
            <ContextMenu.SubmenuRoot>
              <ContextMenu.SubmenuTrigger className="flex items-center justify-between rounded-md px-2 py-1.5 text-sm data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground">
                <span className="inline-flex items-center gap-2">
                  <Share2 className="size-4 text-muted-foreground" />
                  Share
                </span>
                <ChevronRight className="size-4 text-muted-foreground" />
              </ContextMenu.SubmenuTrigger>

              <ContextMenu.Portal>
                <ContextMenu.Positioner sideOffset={6} alignOffset={-4} className="z-50 outline-none">
                  <ContextMenu.Popup className="z-50 min-w-[220px] rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-md">
                    <ContextMenu.Item className="rounded-md px-2 py-1.5 text-sm data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground">
                      Copy link
                    </ContextMenu.Item>
                  </ContextMenu.Popup>
                </ContextMenu.Positioner>
              </ContextMenu.Portal>
            </ContextMenu.SubmenuRoot>
          </ContextMenu.Popup>
        </ContextMenu.Positioner>
      </ContextMenu.Portal>
    </ContextMenu.Root>
  );
}

API reference

Root

A component that creates a context menu activated by right clicking or long pressing. Doesn’t render its own HTML element.

Root Props:

PropTypeDefaultDescription
defaultOpenbooleanfalseWhether the menu is initially open.To render a controlled menu, use the open prop instead.
openboolean-Whether the menu is currently open.
onOpenChange((open: boolean, eventDetails: ContextMenu.Root.ChangeEventDetails) => void)-Event handler called when the menu is opened or closed.
highlightItemOnHoverbooleantrueWhether moving the pointer over items should highlight them. Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state.
actionsRefRefObject<Menu.Root.Actions | null>-A ref to imperative actions.* unmount: When specified, the menu will not be unmounted when closed. Instead, the unmount function must be called to unmount the menu manually. Useful when the menu's animation is controlled by an external library.
* close: When specified, the menu can be closed imperatively.
closeParentOnEscbooleanfalseWhen in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu.
defaultTriggerIdstring | null-ID of the trigger that the popover is associated with. This is useful in conjunction with the defaultOpen prop to create an initially open popover.
handleMenu.Handle<unknown>-A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu's open state.
loopFocusbooleantrueWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
onOpenChangeComplete((open: boolean) => void)-Event handler called after any animations complete when the menu is closed.
triggerIdstring | null-ID of the trigger that the popover is associated with. This is useful in conjunction with the open prop to create a controlled popover. There's no need to specify this prop when the popover is uncontrolled (i.e. when the open prop is not set).
disabledbooleanfalseWhether the component should ignore user interaction.
orientationMenu.Root.Orientation'vertical'The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys.
childrenReactNode | PayloadChildRenderFunction<unknown>-The content of the popover. This can be a regular React node or a render function that receives the payload of the active trigger.

Trigger

An area that opens the menu on right click or long press. Renders a <div> element.

Trigger Props:

PropTypeDefaultDescription
classNamestring | ((state: ContextMenu.Trigger.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: ContextMenu.Trigger.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: ContextMenu.Trigger.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

Trigger Data Attributes:

AttributeTypeDescription
data-popup-open-Present when the corresponding context menu is open.
data-pressed-Present when the trigger is pressed.

Portal

A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to <body>. Renders a <div> element.

Portal Props:

PropTypeDefaultDescription
containerHTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null-A parent element to render the portal element into.
classNamestring | ((state: Menu.Portal.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.Portal.State) => CSSProperties | undefined)--
keepMountedbooleanfalseWhether to keep the portal mounted in the DOM while the popup is hidden.
renderReactElement | ((props: HTMLProps, state: Menu.Portal.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

Positioner

Positions the menu popup against the trigger. Renders a <div> element.

Positioner Props:

PropTypeDefaultDescription
disableAnchorTrackingbooleanfalseWhether to disable the popup from tracking any layout shift of its positioning anchor.
alignAlign'center'How to align the popup relative to the specified side.
alignOffsetnumber | OffsetFunction0Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment.The function takes a data object parameter with the following properties:* data.anchor: the dimensions of the anchor element with properties width and height.
  • data.positioner: the dimensions of the positioner element with properties width and height.
  • data.side: which side of the anchor element the positioner is aligned against.
  • data.align: how the positioner is aligned relative to the specified side. | | side | Side | 'bottom' | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. | | sideOffset | number \| OffsetFunction | 0 | Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment.The function takes a data object parameter with the following properties:* data.anchor: the dimensions of the anchor element with properties width and height.
  • data.positioner: the dimensions of the positioner element with properties width and height.
  • data.side: which side of the anchor element the positioner is aligned against.
  • data.align: how the positioner is aligned relative to the specified side. | | arrowPadding | number | 5 | Minimum distance to maintain between the arrow and the edges of the popup.Use it to prevent the arrow element from hanging out of the rounded corners of a popup. | | anchor | Element \| VirtualElement \| RefObject<Element \| null> \| (() => Element \| VirtualElement \| null) \| null | - | An element to position the popup against. By default, the popup will be positioned against the trigger. | | collisionAvoidance | CollisionAvoidance | - | Determines how to handle collisions when positioning the popup. | | collisionBoundary | Boundary | 'clipping-ancestors' | An element or a rectangle that delimits the area that the popup is confined to. | | collisionPadding | Padding | 5 | Additional space to maintain from the edge of the collision boundary. | | sticky | boolean | false | Whether to maintain the popup in the viewport after the anchor element was scrolled out of view. | | positionMethod | 'absolute' \| 'fixed' | 'absolute' | Determines which CSS position property to use. | | className | string \| ((state: Menu.Positioner.State) => string \| undefined) | - | CSS class applied to the element, or a function that returns a class based on the component’s state. | | style | CSSProperties \| ((state: Menu.Positioner.State) => CSSProperties \| undefined) | - | - | | render | ReactElement \| ((props: HTMLProps, state: Menu.Positioner.State) => ReactElement) | - | Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render. |

Positioner Data Attributes:

AttributeTypeDescription
data-open-Present when the menu popup is open.
data-closed-Present when the menu popup is closed.
data-anchor-hidden-Present when the anchor is hidden.
data-align'start' | 'center' | 'end'Indicates how the popup is aligned relative to specified side.
data-side'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'Indicates which side the popup is positioned relative to the trigger.

Positioner CSS Variables:

VariableTypeDefaultDescription
--anchor-heightnumber-The anchor's height.
--anchor-widthnumber-The anchor's width.
--available-heightnumber-The available height between the trigger and the edge of the viewport.
--available-widthnumber-The available width between the trigger and the edge of the viewport.
--transform-originstring-The coordinates that this element is anchored to. Used for animations and transitions.

A container for the menu items. Renders a <div> element.

Popup Props:

PropTypeDefaultDescription
finalFocusboolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)-Determines the element to focus when the menu is closed.* false: Do not move focus.
  • true: Move focus based on the default behavior (trigger or previously focused element).
  • RefObject: Move focus to the ref element.
  • function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, or false/undefined to do nothing. | | children | ReactNode | - | - | | className | string \| ((state: Menu.Popup.State) => string \| undefined) | - | CSS class applied to the element, or a function that returns a class based on the component’s state. | | style | CSSProperties \| ((state: Menu.Popup.State) => CSSProperties \| undefined) | - | * | | render | ReactElement \| ((props: HTMLProps, state: Menu.Popup.State) => ReactElement) | - | Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render. |

Popup Data Attributes:

AttributeTypeDescription
data-open-Present when the menu is open.
data-closed-Present when the menu is closed.
data-align'start' | 'center' | 'end'Indicates how the popup is aligned relative to specified side.
data-instant'click' | 'dismiss' | 'group'Present if animations should be instant.
data-side'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'Indicates which side the popup is positioned relative to the trigger.
data-starting-style-Present when the menu is animating in.
data-ending-style-Present when the menu is animating out.

Arrow

Displays an element positioned against the menu anchor. Renders a <div> element.

Arrow Props:

PropTypeDefaultDescription
classNamestring | ((state: Menu.Arrow.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.Arrow.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.Arrow.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

Arrow Data Attributes:

AttributeTypeDescription
data-open-Present when the menu popup is open.
data-closed-Present when the menu popup is closed.
data-uncentered-Present when the menu arrow is uncentered.
data-align'start' | 'center' | 'end'Indicates how the popup is aligned relative to specified side.
data-side'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'Indicates which side the popup is positioned relative to the trigger.

Item

An individual interactive item in the menu. Renders a <div> element.

Item Props:

PropTypeDefaultDescription
labelstring-Overrides the text label to use when the item is matched during keyboard text navigation.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)-The click handler for the menu item.
closeOnClickbooleantrueWhether to close the menu when the item is clicked.
nativeButtonbooleanfalseWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
disabledbooleanfalseWhether the component should ignore user interaction.
classNamestring | ((state: Menu.Item.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.Item.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.Item.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

Item Data Attributes:

AttributeTypeDescription
data-highlighted-Present when the menu item is highlighted.
data-disabled-Present when the menu item is disabled.

LinkItem

A link in the menu that can be used to navigate to a different page or section. Renders an <a> element.

LinkItem Props:

PropTypeDefaultDescription
labelstring-Overrides the text label to use when the item is matched during keyboard text navigation.
closeOnClickbooleanfalseWhether to close the menu when the item is clicked.
classNamestring | ((state: Menu.LinkItem.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.LinkItem.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.LinkItem.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

LinkItem Data Attributes:

AttributeTypeDescription
data-highlighted-Present when the link is highlighted.

Groups all parts of a submenu. Doesn’t render its own HTML element.

SubmenuRoot Props:

PropTypeDefaultDescription
defaultOpenbooleanfalseWhether the menu is initially open.To render a controlled menu, use the open prop instead.
openboolean-Whether the menu is currently open.
onOpenChange((open: boolean, eventDetails: Menu.SubmenuRoot.ChangeEventDetails) => void)-Event handler called when the menu is opened or closed.
highlightItemOnHoverbooleantrueWhether moving the pointer over items should highlight them. Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state.
actionsRefRefObject<Menu.Root.Actions | null>-A ref to imperative actions.* unmount: When specified, the menu will not be unmounted when closed. Instead, the unmount function must be called to unmount the menu manually. Useful when the menu's animation is controlled by an external library.
* close: When specified, the menu can be closed imperatively.
closeParentOnEscbooleanfalseWhen in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu.
defaultTriggerIdstring | null-ID of the trigger that the popover is associated with. This is useful in conjunction with the defaultOpen prop to create an initially open popover.
handleMenu.Handle<unknown>-A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu's open state.
loopFocusbooleantrueWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
onOpenChangeComplete((open: boolean) => void)-Event handler called after any animations complete when the menu is closed.
triggerIdstring | null-ID of the trigger that the popover is associated with. This is useful in conjunction with the open prop to create a controlled popover. There's no need to specify this prop when the popover is uncontrolled (i.e. when the open prop is not set).
disabledbooleanfalseWhether the component should ignore user interaction.
orientationMenu.Root.Orientation'vertical'The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys.
childrenReactNode | PayloadChildRenderFunction<unknown>-The content of the popover. This can be a regular React node or a render function that receives the payload of the active trigger.

A menu item that opens a submenu. Renders a <div> element.

SubmenuTrigger Props:

PropTypeDefaultDescription
labelstring-Overrides the text label to use when the item is matched during keyboard text navigation.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)--
nativeButtonbooleanfalseWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
disabledbooleanfalseWhether the component should ignore user interaction.
openOnHoverboolean-Whether the menu should also open when the trigger is hovered.
delaynumber100How long to wait before the menu may be opened on hover. Specified in milliseconds.Requires the openOnHover prop.
closeDelaynumber0How long to wait before closing the menu that was opened on hover. Specified in milliseconds.Requires the openOnHover prop.
classNamestring | ((state: Menu.SubmenuTrigger.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.SubmenuTrigger.State) => CSSProperties | undefined)-*
renderReactElement | ((props: HTMLProps, state: Menu.SubmenuTrigger.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

SubmenuTrigger Data Attributes:

AttributeTypeDescription
data-popup-open-Present when the corresponding submenu is open.
data-highlighted-Present when the submenu trigger is highlighted.
data-disabled-Present when the submenu trigger is disabled.

Group

Groups related menu items with the corresponding label. Renders a <div> element.

Group Props:

PropTypeDefaultDescription
childrenReactNode-The content of the component.
classNamestring | ((state: Menu.Group.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.Group.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.Group.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

GroupLabel

An accessible label that is automatically associated with its parent group. Renders a <div> element.

GroupLabel Props:

PropTypeDefaultDescription
classNamestring | ((state: Menu.GroupLabel.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.GroupLabel.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.GroupLabel.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

RadioGroup

Groups related radio items. Renders a <div> element.

RadioGroup Props:

PropTypeDefaultDescription
defaultValueany-The uncontrolled value of the radio item that should be initially selected.To render a controlled radio group, use the value prop instead.
valueany-The controlled value of the radio item that should be currently selected.To render an uncontrolled radio group, use the defaultValue prop instead.
onValueChange((value: any, eventDetails: Menu.RadioGroup.ChangeEventDetails) => void)-Function called when the selected value changes.
disabledbooleanfalseWhether the component should ignore user interaction.
childrenReactNode-The content of the component.
classNamestring | ((state: Menu.RadioGroup.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.RadioGroup.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.RadioGroup.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

RadioItem

A menu item that works like a radio button in a given group. Renders a <div> element.

RadioItem Props:

PropTypeDefaultDescription
labelstring-Overrides the text label to use when the item is matched during keyboard text navigation.
valueany-Value of the radio item. This is the value that will be set in the Menu.RadioGroup when the item is selected.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)-The click handler for the menu item.
closeOnClickbooleanfalseWhether to close the menu when the item is clicked.
nativeButtonbooleanfalseWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
disabledbooleanfalseWhether the component should ignore user interaction.
classNamestring | ((state: Menu.RadioItem.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.RadioItem.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.RadioItem.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

RadioItem Data Attributes:

AttributeTypeDescription
data-checked-Present when the menu radio item is selected.
data-unchecked-Present when the menu radio item is not selected.
data-highlighted-Present when the menu radio item is highlighted.
data-disabled-Present when the menu radio item is disabled.

RadioItemIndicator

Indicates whether the radio item is selected. Renders a <span> element.

RadioItemIndicator Props:

PropTypeDefaultDescription
classNamestring | ((state: Menu.RadioItemIndicator.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.RadioItemIndicator.State) => CSSProperties | undefined)--
keepMountedbooleanfalseWhether to keep the HTML element in the DOM when the radio item is inactive.
renderReactElement | ((props: HTMLProps, state: Menu.RadioItemIndicator.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

RadioItemIndicator Data Attributes:

AttributeTypeDescription
data-checked-Present when the menu radio item is selected.
data-unchecked-Present when the menu radio item is not selected.
data-disabled-Present when the menu radio item is disabled.
data-starting-style-Present when the radio indicator is animating in.
data-ending-style-Present when the radio indicator is animating out.

CheckboxItem

A menu item that toggles a setting on or off. Renders a <div> element.

CheckboxItem Props:

PropTypeDefaultDescription
labelstring-Overrides the text label to use when the item is matched during keyboard text navigation.
defaultCheckedbooleanfalseWhether the checkbox item is initially ticked.To render a controlled checkbox item, use the checked prop instead.
checkedboolean-Whether the checkbox item is currently ticked.To render an uncontrolled checkbox item, use the defaultChecked prop instead.
onCheckedChange((checked: boolean, eventDetails: Menu.CheckboxItem.ChangeEventDetails) => void)-Event handler called when the checkbox item is ticked or unticked.
onClick((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)-The click handler for the menu item.
closeOnClickbooleanfalseWhether to close the menu when the item is clicked.
nativeButtonbooleanfalseWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
disabledbooleanfalseWhether the component should ignore user interaction.
classNamestring | ((state: Menu.CheckboxItem.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.CheckboxItem.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Menu.CheckboxItem.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

CheckboxItem Data Attributes:

AttributeTypeDescription
data-checked-Present when the menu checkbox item is checked.
data-unchecked-Present when the menu checkbox item is not checked.
data-highlighted-Present when the menu checkbox item is highlighted.
data-disabled-Present when the menu checkbox item is disabled.

CheckboxItemIndicator

Indicates whether the checkbox item is ticked. Renders a <span> element.

CheckboxItemIndicator Props:

PropTypeDefaultDescription
classNamestring | ((state: Menu.CheckboxItemIndicator.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Menu.CheckboxItemIndicator.State) => CSSProperties | undefined)--
keepMountedbooleanfalseWhether to keep the HTML element in the DOM when the checkbox item is not checked.
renderReactElement | ((props: HTMLProps, state: Menu.CheckboxItemIndicator.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

CheckboxItemIndicator Data Attributes:

AttributeTypeDescription
data-checked-Present when the menu checkbox item is checked.
data-unchecked-Present when the menu checkbox item is not checked.
data-disabled-Present when the menu checkbox item is disabled.
data-starting-style-Present when the indicator is animating in.
data-ending-style-Present when the indicator is animating out.

Separator

A separator element accessible to screen readers. Renders a <div> element.

Separator Props:

PropTypeDefaultDescription
orientationOrientation'horizontal'The orientation of the separator.
classNamestring | ((state: Separator.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Separator.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Separator.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

On this page