Menubar
The Menubar component is a visually persistent menu, commonly used in desktop applications, that provides quick access to a consistent set of commands. It ensures efficient workflow and ease of use by keeping essential functions readily accessible at all times.
Configurable Props
<Menubar>
Prop | Type | Default/ Options | Description |
---|---|---|---|
defaultValue | string | The value of the menu that should be open when initially rendered. Use when you do not need to control the value state. | |
value | string | The controlled value of the menu to open. Should be used in conjunction with onValueChange. | |
onValueChange | function (open: string) => void | Event handler called when the value changes. | |
loop | boolean | false | When true, keyboard navigation will loop from last item to first, and vice versa. |
<MenubarTrigger>
Prop | Type | Default/ Options | Description |
---|---|---|---|
asChild | boolean | false | Change the default rendered element for the one passed as a child, merging their props and behavior. |
<MenubarContent>
Prop | Type | Default/ Options | Description |
---|---|---|---|
loop | boolean | false | When true, keyboard navigation will loop from last item to first, and vice versa. |
onCloseAutoFocus | function (event: Event) => void | Event handler called when focus moves back after closing. It can be prevented by calling event.preventDefault. | |
onEscapeKeyDown | function (event: KeyboardEvent) => void | Event handler called when the escape key is down. It can be prevented by calling event.preventDefault | |
onPointerDownOutside | function (event: PointerDownOutsideEvent) => void | Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault. | |
onFocusOutside | function (event: FocusOutsideEvent) => void | Event handler called when focus moves outside the bounds of the component. It can be prevented by calling event.preventDefault. | |
onInteractOutside | function (event: PointerDownOutsideEvent | FocusOutsideEvent) => void | Event handler called when focus moves outside the bounds of the component. It can be prevented by calling event.preventDefault. | |
side | enum | bottom ("top" | "right" | "bottom" | "left") | The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled. |
sideOffset | number | 0 | The distance in pixels from the trigger. |
align | enum | center ("start" | "center" | "end") | The distance in pixels from the trigger. |
alignOffset | number | 0 | The vertical distance in pixels from the anchor. |
avoidCollisions | boolean | true | When true, overrides the side andalign preferences to prevent collisions with boundary edges. |
collisionBoundary | Boundary | [] | The element used as the collision boundary. By default this is the viewport, though you can provide additional element(s) to be included in this check. |
collisionPadding | number | Padding | 0 | The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: |
sticky | enum "partial" | "always" | "partial" | The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: |
hideWhenDetached | boolean | false | Whether to hide the content when the trigger becomes fully occluded. |
<MenubarItem>
Prop | Type | Default/ Options | Description |
---|---|---|---|
disabled | boolean | false | When true, prevents the user from interacting with the item. |
onSelect | function (event: Event) => void | Event handler called when the user selects an item (via mouse or keyboard). Calling event.preventDefault in this handler will prevent the dropdown menu from closing when selecting that item. | |
textValue | string | Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. |
<MenubarCheckboxItem>
Prop | Type | Default/ Options | Description |
---|---|---|---|
checked | boolean | 'indeterminate' | The controlled checked state of the item. Must be used in conjunction with onCheckedChange. | |
onCheckedChange | function (checked: boolean) => void | Event handler called when the checked state changes. | |
disabled | boolean | When true, prevents the user from interacting with the item. | |
onSelect | function (event: Event) => void | Event handler called when the user selects an item (via mouse or keyboard). Calling event.preventDefault in this handler will prevent the dropdown menu from closing when selecting that item. | |
textValue | string | Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. |
<MenubarRadioGroup>
Prop | Type | Default/ Options | Description |
---|---|---|---|
value | string | The value of the selected item in the group. | |
onValueChange | function (value: string) => void | Event handler called when the value changes. |
<MenubarRadioItem>
Prop | Type | Default/ Options | Description |
---|---|---|---|
value* | string | The value of the selected item in the group. | |
disabled | boolean | When true, prevents the user from interacting with the item. | |
onSelect | function (event: Event) => void | Event handler called when the user selects an item (via mouse or keyboard). Calling event.preventDefault in this handler will prevent the dropdown menu from closing when selecting that item. | |
textValue | string | Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. |
<MenubarSub>
Prop | Type | Default/ Options | Description |
---|---|---|---|
defaultOpen | boolean | The open state of the submenu when it is initially rendered. Use when you do not need to control its open state. | |
open | boolean | The controlled open state of the submenu. Must be used in conjunction with onOpenChange. | |
onOpenChange | function (open: boolean) => void | Event handler called when the open state of the submenu changes. |
<MenubarSubTrigger>
Prop | Type | Default/ Options | Description |
---|---|---|---|
disabled | boolean | false | When true, prevents the user from interacting with the item. |
textValue | string | false | Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside. |
<MenubarSubContent>
Prop | Type | Default/ Options | Description |
---|---|---|---|
loop | boolean | false | When true, keyboard navigation will loop from last item to first, and vice versa. |
onEscapeKeyDown | function (event: KeyboardEvent) => void | Event handler called when the escape key is down. It can be prevented by calling event.preventDefault | |
onPointerDownOutside | function (event: PointerDownOutsideEvent) => void | Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault. | |
onFocusOutside | function (event: FocusOutsideEvent) => void | Event handler called when focus moves outside the bounds of the component. It can be prevented by calling event.preventDefault. | |
onInteractOutside | function (event: PointerDownOutsideEvent | FocusOutsideEvent) => void | Event handler called when focus moves outside the bounds of the component. It can be prevented by calling event.preventDefault. | |
sideOffset | number | 0 | The distance in pixels from the trigger. |
alignOffset | number | 0 | The vertical distance in pixels from the anchor. |
avoidCollisions | boolean | true | When true, overrides the side andalign preferences to prevent collisions with boundary edges. |
collisionBoundary | Boundary | [] | The element used as the collision boundary. By default this is the viewport, though you can provide additional element(s) to be included in this check. |
collisionPadding | number | Padding | 0 | The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: |
sticky | enum "partial" | "always" | "partial" | The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: |
hideWhenDetached | boolean | false | Whether to hide the content when the trigger becomes fully occluded. |