structyl

Menubar API

View component

The full prop reference for the Menubar component. A horizontal bar of dropdown menus, like a desktop app.

Import

tsx
import { Menubar } from '@structyl/styled';

Props

Root

Main container for the menubar. Manages open state and keyboard navigation across all menu items.

PropTypeDefault
value#string

Controlled open menu ID (identifies which menu is currently open)

defaultValue#string

Initial open menu ID when uncontrolled

onValueChange#(value: string) => void

Callback when the open menu changes

dir#'ltr' | 'rtl'

Text direction (left-to-right or right-to-left)

loop#boolean

Whether keyboard navigation wraps around at list boundaries

true
asChild#boolean

Render as child element instead of div

className#string

CSS class names

Menu

Container for a single menu trigger and its content. Use multiple Menu components for multiple menu items in the bar.

PropTypeDefault
value#string

Optional unique identifier for this menu (auto-generated if not provided)

children#React.ReactNode

Child elements (typically Trigger and Content)

Trigger

Button that opens/closes a menu. Placed inside Menu.

PropTypeDefault
disabled#boolean

Whether the trigger is disabled

asChild#boolean

Render as child element instead of button

className#string

CSS class names

Content

Container for menu items. Appears as a popover below the trigger.

PropTypeDefault
side#'top' | 'right' | 'bottom' | 'left'

Which side of the trigger to position the menu

sideOffset#number

Distance in pixels from the trigger

8
align#'start' | 'center' | 'end'

Alignment relative to trigger (start, center, or end)

alignOffset#number

Offset from the align position

forceMount#boolean

Keep in DOM even when closed

loop#boolean

Whether focus wraps around menu items

avoidCollisions#boolean

Flip position to avoid viewport collisions

collisionBoundary#Element | Element[] | null

Elements that define collision detection boundary

collisionPadding#number

Padding around collision boundary

sticky#'partial' | 'always'

Keep menu visible during partial scrolling

hideWhenDetached#boolean

Hide when trigger becomes detached from viewport

updatePositionStrategy#'always' | 'optimized'

When to update position during scroll

onCloseAutoFocus#(event: Event) => void

Called when focus returns to trigger on close

onEscapeKeyDown#(event: KeyboardEvent) => void

Called when Escape key is pressed

onPointerDownOutside#(event: PointerDownOutsideEvent) => void

Called when pointer down occurs outside content

onFocusOutside#(event: FocusOutsideEvent) => void

Called when focus moves outside content

onInteractOutside#(event: PointerDownOutsideEvent | FocusOutsideEvent) => void

Called for any interaction outside content

asChild#boolean

Render as child element instead of div

className#string

CSS class names

Item

A clickable menu item. Can contain text or arbitrary children.

PropTypeDefault
disabled#boolean

Whether the item is disabled

onSelect#(event: Event) => void

Called when the item is selected (clicked or Enter pressed)

textValue#string

Optional text value for typeahead search

inset#boolean

Add left padding for alignment with checkbox/radio items (styled only)

asChild#boolean

Render as child element instead of div

className#string

CSS class names

CheckboxItem

Menu item with a checkbox that toggles on/off.

PropTypeDefault
checked#boolean | 'indeterminate'

Whether the checkbox is checked or in indeterminate state

false
onCheckedChange#(checked: boolean) => void

Called when the checked state changes

disabled#boolean

Whether the item is disabled

onSelect#(event: Event) => void

Called when the item is selected

textValue#string

Optional text value for typeahead search

asChild#boolean

Render as child element instead of div

className#string

CSS class names

RadioGroup

Container for radio items where only one can be selected at a time.

PropTypeDefault
value#string

Currently selected radio item value

onValueChange#(value: string) => void

Called when the selected radio item changes

asChild#boolean

Render as child element instead of div

className#string

CSS class names

RadioItem

A radio button menu item. Must be inside RadioGroup.

PropTypeDefault
value#string

Unique value for this radio item (required)

disabled#boolean

Whether the item is disabled

onSelect#(event: Event) => void

Called when the item is selected

textValue#string

Optional text value for typeahead search

asChild#boolean

Render as child element instead of div

className#string

CSS class names

Sub

Container for a submenu. Must contain SubTrigger and SubContent.

PropTypeDefault
open#boolean

Controlled open state for the submenu

defaultOpen#boolean

Initial open state when uncontrolled

onOpenChange#(open: boolean) => void

Called when the submenu open state changes

children#React.ReactNode

Child elements (SubTrigger and SubContent)

SubTrigger

Button that opens/closes a submenu. Placed inside Sub.

PropTypeDefault
disabled#boolean

Whether the trigger is disabled

onSelect#(event: Event) => void

Called when the trigger is selected

textValue#string

Optional text value for typeahead search

inset#boolean

Add left padding for alignment (styled only)

asChild#boolean

Render as child element instead of div

className#string

CSS class names

SubContent

Container for submenu items. Appears as a popover to the side of the SubTrigger.

PropTypeDefault
loop#boolean

Whether focus wraps around submenu items

forceMount#boolean

Keep in DOM even when closed

onCloseAutoFocus#(event: Event) => void

Called when focus returns on close

onEscapeKeyDown#(event: KeyboardEvent) => void

Called when Escape key is pressed

onPointerDownOutside#(event: PointerDownOutsideEvent) => void

Called when pointer down occurs outside

onFocusOutside#(event: FocusOutsideEvent) => void

Called when focus moves outside

onInteractOutside#(event: PointerDownOutsideEvent | FocusOutsideEvent) => void

Called for any interaction outside

asChild#boolean

Render as child element instead of div

className#string

CSS class names

Group

Container to group related menu items.

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class names

Label

Non-interactive label or section heading inside a menu.

PropTypeDefault
inset#boolean

Add left padding for alignment (styled only)

asChild#boolean

Render as child element instead of div

className#string

CSS class names

Separator

Visual divider between menu items.

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class names

ItemIndicator

Displays the check mark or radio dot icon. Automatically shown/hidden based on checked state.

PropTypeDefault
forceMount#boolean

Keep in DOM even when not checked

asChild#boolean

Render as child element instead of span

className#string

CSS class names

Portal

Renders menu content in a portal (typically at document root). Optional; Content wraps this automatically.

PropTypeDefault
container#Element | DocumentFragment | null

Optional custom DOM node to render portal into

forceMount#boolean

Keep portal content in DOM even when menu is closed

children#React.ReactNode

Child elements to render in portal

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library