📄 radixui/primitives/docs/components/menubar

File: menubar.md | Updated: 11/15/2025

Source: https://www.radix-ui.com/primitives/docs/components/menubar

Radix Homepage

Made by WorkOS

Radix Homepage

Made by WorkOS

ThemesThemes PrimitivesPrimitives IconsIcons ColorsColors

Documentation Case studies Blog

Search

/

Overview

Introduction Getting started Accessibility Releases

Guides

Styling Animation Composition Server-side rendering

Components

Accordion Alert Dialog Aspect Ratio Avatar Checkbox Collapsible Context Menu Dialog Dropdown Menu Form

Preview
Hover Card Label Menubar Navigation Menu One-Time Password Field

Preview
Password Toggle Field

Preview
Popover Progress Radio Group Scroll Area Select Separator Slider Switch Tabs Toast Toggle Toggle Group Toolbar Tooltip

Utilities

Accessible Icon Direction Provider Portal Slot Visually Hidden

Components

Menu Bar

A visually persistent menu common in desktop applications that provides quick access to a consistent set of commands.

FileEditViewProfiles

index.jsxindex.jsxstyles.cssstyles.css

CSS

import * as React from "react";
import { Menubar } from "radix-ui";
import {
	CheckIcon,
	ChevronRightIcon,
	DotFilledIcon,
} from "@radix-ui/react-icons";
import "./styles.css";

const RADIO_ITEMS = ["Andy", "Benoît", "Luis"];
const CHECK_ITEMS = ["Always Show Bookmarks Bar", "Always Show Full URLs"];

const MenubarDemo = () => {
	const [checkedSelection, setCheckedSelection] = React.useState([\
		CHECK_ITEMS[1],\
	]);
	const [radioSelection, setRadioSelection] = React.useState(RADIO_ITEMS[2]);

	return (
		<Menubar.Root className="MenubarRoot">
			<Menubar.Menu>
				<Menubar.Trigger className="MenubarTrigger">File</Menubar.Trigger>
				<Menubar.Portal>
					<Menubar.Content
						className="MenubarContent"
						align="start"
						sideOffset={5}
						alignOffset={-3}
					>
						<Menubar.Item className="MenubarItem">
							New Tab <div className="RightSlot">⌘ T</div>
						</Menubar.Item>
						<Menubar.Item className="MenubarItem">
							New Window <div className="RightSlot">⌘ N</div>
						</Menubar.Item>
						<Menubar.Item className="MenubarItem" disabled>
							New Incognito Window
						</Menubar.Item>
						<Menubar.Separator className="MenubarSeparator" />
						<Menubar.Sub>
							<Menubar.SubTrigger className="MenubarSubTrigger">
								Share
								<div className="RightSlot">
									<ChevronRightIcon />
								</div>
							</Menubar.SubTrigger>
							<Menubar.Portal>
								<Menubar.SubContent
									className="MenubarSubContent"
									alignOffset={-5}
								>
									<Menubar.Item className="MenubarItem">
										Email Link
									</Menubar.Item>
									<Menubar.Item className="MenubarItem">Messages</Menubar.Item>
									<Menubar.Item className="MenubarItem">Notes</Menubar.Item>
								</Menubar.SubContent>
							</Menubar.Portal>
						</Menubar.Sub>
						<Menubar.Separator className="MenubarSeparator" />
						<Menubar.Item className="MenubarItem">
							Print… <div className="RightSlot">⌘ P</div>
						</Menubar.Item>
					</Menubar.Content>
				</Menubar.Portal>
			</Menubar.Menu>

			<Menubar.Menu>
				<Menubar.Trigger className="MenubarTrigger">Edit</Menubar.Trigger>
				<Menubar.Portal>
					<Menubar.Content
						className="MenubarContent"
						align="start"
						sideOffset={5}
						alignOffset={-3}
					>
						<Menubar.Item className="MenubarItem">
							Undo <div className="RightSlot">⌘ Z</div>
						</Menubar.Item>
						<Menubar.Item className="MenubarItem">
							Redo <div className="RightSlot">⇧ ⌘ Z</div>
						</Menubar.Item>
						<Menubar.Separator className="MenubarSeparator" />
						<Menubar.Sub>
							<Menubar.SubTrigger className="MenubarSubTrigger">
								Find
								<div className="RightSlot">
									<ChevronRightIcon />
								</div>
							</Menubar.SubTrigger>

							<Menubar.Portal>
								<Menubar.SubContent
									className="MenubarSubContent"
									alignOffset={-5}
								>
									<Menubar.Item className="MenubarItem">
										Search the web…
									</Menubar.Item>
									<Menubar.Separator className="MenubarSeparator" />
									<Menubar.Item className="MenubarItem">Find…</Menubar.Item>
									<Menubar.Item className="MenubarItem">Find Next</Menubar.Item>
									<Menubar.Item className="MenubarItem">
										Find Previous
									</Menubar.Item>
								</Menubar.SubContent>
							</Menubar.Portal>
						</Menubar.Sub>
						<Menubar.Separator className="MenubarSeparator" />
						<Menubar.Item className="MenubarItem">Cut</Menubar.Item>
						<Menubar.Item className="MenubarItem">Copy</Menubar.Item>
						<Menubar.Item className="MenubarItem">Paste</Menubar.Item>
					</Menubar.Content>
				</Menubar.Portal>
			</Menubar.Menu>

			<Menubar.Menu>
				<Menubar.Trigger className="MenubarTrigger">View</Menubar.Trigger>
				<Menubar.Portal>
					<Menubar.Content
						className="MenubarContent"
						align="start"
						sideOffset={5}
						alignOffset={-14}
					>
						{CHECK_ITEMS.map((item) => (
							<Menubar.CheckboxItem
								className="MenubarCheckboxItem inset"
								key={item}
								checked={checkedSelection.includes(item)}
								onCheckedChange={() =>
									setCheckedSelection((current) =>
										current.includes(item)
											? current.filter((el) => el !== item)
											: current.concat(item),
									)
								}
							>
								<Menubar.ItemIndicator className="MenubarItemIndicator">
									<CheckIcon />
								</Menubar.ItemIndicator>
								{item}
							</Menubar.CheckboxItem>
						))}
						<Menubar.Separator className="MenubarSeparator" />
						<Menubar.Item className="MenubarItem inset">
							Reload <div className="RightSlot">⌘ R</div>
						</Menubar.Item>
						<Menubar.Item className="MenubarItem inset" disabled>
							Force Reload <div className="RightSlot">⇧ ⌘ R</div>
						</Menubar.Item>
						<Menubar.Separator className="MenubarSeparator" />
						<Menubar.Item className="MenubarItem inset">
							Toggle Fullscreen
						</Menubar.Item>
						<Menubar.Separator className="MenubarSeparator" />
						<Menubar.Item className="MenubarItem inset">
							Hide Sidebar
						</Menubar.Item>
					</Menubar.Content>
				</Menubar.Portal>
			</Menubar.Menu>

			<Menubar.Menu>
				<Menubar.Trigger className="MenubarTrigger">Profiles</Menubar.Trigger>
				<Menubar.Portal>
					<Menubar.Content
						className="MenubarContent"
						align="start"
						sideOffset={5}
						alignOffset={-14}
					>
						<Menubar.RadioGroup
							value={radioSelection}
							onValueChange={setRadioSelection}
						>
							{RADIO_ITEMS.map((item) => (
								<Menubar.RadioItem
									className="MenubarRadioItem inset"
									key={item}
									value={item}
								>
									<Menubar.ItemIndicator className="MenubarItemIndicator">
										<DotFilledIcon />
									</Menubar.ItemIndicator>
									{item}
								</Menubar.RadioItem>
							))}
							<Menubar.Separator className="MenubarSeparator" />
							<Menubar.Item className="MenubarItem inset">Edit…</Menubar.Item>
							<Menubar.Separator className="MenubarSeparator" />
							<Menubar.Item className="MenubarItem inset">
								Add Profile…
							</Menubar.Item>
						</Menubar.RadioGroup>
					</Menubar.Content>
				</Menubar.Portal>
			</Menubar.Menu>
		</Menubar.Root>
	);
};

export default MenubarDemo;

Features

Can be controlled or uncontrolled.

Supports submenus with configurable reading direction.

Supports items, labels, groups of items.

Supports checkable items (single or multiple).

Customize side, alignment, offsets, collision handling.

Optionally render a pointing arrow.

Focus is fully managed.

Full keyboard navigation.

Typeahead support.

Installation


Install the component from your command line.

npm install @radix-ui/react-menubar

Anatomy


Import all parts and piece them together.

import { Menubar } from "radix-ui";

export default () => (
	<Menubar.Root>
		<Menubar.Menu>
			<Menubar.Trigger />
			<Menubar.Portal>
				<Menubar.Content>
					<Menubar.Label />
					<Menubar.Item />

					<Menubar.Group>
						<Menubar.Item />
					</Menubar.Group>

					<Menubar.CheckboxItem>
						<Menubar.ItemIndicator />
					</Menubar.CheckboxItem>

					<Menubar.RadioGroup>
						<Menubar.RadioItem>
							<Menubar.ItemIndicator />
						</Menubar.RadioItem>
					</Menubar.RadioGroup>

					<Menubar.Sub>
						<Menubar.SubTrigger />
						<Menubar.Portal>
							<Menubar.SubContent />
						</Menubar.Portal>
					</Menubar.Sub>

					<Menubar.Separator />
					<Menubar.Arrow />
				</Menubar.Content>
			</Menubar.Portal>
		</Menubar.Menu>
	</Menubar.Root>
);

API Reference


Root

Contains all the parts of a menubar.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | defaultValue<br><br>Prop description | string | No default value | | value<br><br>Prop description | string | No default value | | onValueChange<br><br>Prop description | function<br><br>See full type | No default value | | dir<br><br>Prop description | enum<br><br>See full type | No default value | | loop<br><br>Prop description | boolean | false |

Menu

A top level menu item, contains a trigger with content combination.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | value<br><br>Prop description | string | No default value |

Trigger

The button that toggles the content. By default, the Menubar.Content will position itself against the trigger.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false |

| Data attribute | Values | | --- | --- | | [data-state] | "open" \| "closed" | | [data-highlighted] | Present when highlighted | | [data-disabled] | Present when disabled |

Portal

When used, portals the content part into the body.

| Prop | Type | Default | | --- | --- | --- | | forceMount<br><br>Prop description | boolean | No default value | | container<br><br>Prop description | HTMLElement | document.body |

Content

The component that pops out when a menu is open.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | loop<br><br>Prop description | boolean | false | | onCloseAutoFocus<br><br>Prop description | function<br><br>See full type | No default value | | onEscapeKeyDown<br><br>Prop description | function<br><br>See full type | No default value | | onPointerDownOutside<br><br>Prop description | function<br><br>See full type | No default value | | onFocusOutside<br><br>Prop description | function<br><br>See full type | No default value | | onInteractOutside<br><br>Prop description | function<br><br>See full type | No default value | | forceMount<br><br>Prop description | boolean | No default value | | side<br><br>Prop description | enum<br><br>See full type | "bottom" | | sideOffset<br><br>Prop description | number | 0 | | align<br><br>Prop description | enum<br><br>See full type | "center" | | alignOffset<br><br>Prop description | number | 0 | | avoidCollisions<br><br>Prop description | boolean | true | | collisionBoundary<br><br>Prop description | Boundary<br><br>See full type | [] | | collisionPadding<br><br>Prop description | number \| Padding<br><br>See full type | 0 | | arrowPadding<br><br>Prop description | number | 0 | | sticky<br><br>Prop description | enum<br><br>See full type | "partial" | | hideWhenDetached<br><br>Prop description | boolean | false |

| Data attribute | Values | | --- | --- | | [data-state] | "open" \| "closed" | | [data-side] | "left" \| "right" \| "bottom" \| "top" | | [data-align] | "start" \| "end" \| "center" |

| CSS Variable | Description | | --- | --- | | --radix-menubar-content-transform-origin | The transform-origin computed from the content and arrow positions/offsets | | --radix-menubar-content-available-width | The remaining width between the trigger and the boundary edge | | --radix-menubar-content-available-height | The remaining height between the trigger and the boundary edge | | --radix-menubar-trigger-width | The width of the trigger | | --radix-menubar-trigger-height | The height of the trigger |

Arrow

An optional arrow element to render alongside a menubar menu. This can be used to help visually link the trigger with the Menubar.Content. Must be rendered inside Menubar.Content.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | width<br><br>Prop description | number | 10 | | height<br><br>Prop description | number | 5 |

Item

The component that contains the menubar items.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | disabled<br><br>Prop description | boolean | No default value | | onSelect<br><br>Prop description | function<br><br>See full type | No default value | | textValue<br><br>Prop description | string | No default value |

| Data attribute | Values | | --- | --- | | [data-highlighted] | Present when highlighted | | [data-disabled] | Present when disabled |

Group

Used to group multiple Menubar.Items.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false |

Label

Used to render a label. It won't be focusable using arrow keys.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false |

CheckboxItem

An item that can be controlled and rendered like a checkbox.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | checked<br><br>Prop description | boolean \| 'indeterminate' | No default value | | onCheckedChange<br><br>Prop description | function<br><br>See full type | No default value | | disabled<br><br>Prop description | boolean | No default value | | onSelect<br><br>Prop description | function<br><br>See full type | No default value | | textValue<br><br>Prop description | string | No default value |

| Data attribute | Values | | --- | --- | | [data-state] | "checked" \| "unchecked" | | [data-highlighted] | Present when highlighted | | [data-disabled] | Present when disabled |

RadioGroup

Used to group multiple Menubar.RadioItems.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | value<br><br>Prop description | string | No default value | | onValueChange<br><br>Prop description | function<br><br>See full type | No default value |

RadioItem

An item that can be controlled and rendered like a radio.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | value*<br><br>Prop description | string | No default value | | disabled<br><br>Prop description | boolean | No default value | | onSelect<br><br>Prop description | function<br><br>See full type | No default value | | textValue<br><br>Prop description | string | No default value |

| Data attribute | Values | | --- | --- | | [data-state] | "checked" \| "unchecked" | | [data-highlighted] | Present when highlighted | | [data-disabled] | Present when disabled |

ItemIndicator

Renders when the parent Menubar.CheckboxItem or Menubar.RadioItem is checked. You can style this element directly, or you can use it as a wrapper to put an icon into, or both.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | forceMount<br><br>Prop description | boolean | No default value |

| Data attribute | Values | | --- | --- | | [data-state] | "checked" \| "unchecked" |

Separator

Used to visually separate items in a menubar menu.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false |

Sub

Contains all the parts of a submenu.

| Prop | Type | Default | | --- | --- | --- | | defaultOpen<br><br>Prop description | boolean | No default value | | open<br><br>Prop description | boolean | No default value | | onOpenChange<br><br>Prop description | function<br><br>See full type | No default value |

SubTrigger

An item that opens a submenu. Must be rendered inside Menubar.Sub.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | disabled<br><br>Prop description | boolean | No default value | | textValue<br><br>Prop description | string | No default value |

| Data attribute | Values | | --- | --- | | [data-state] | "open" \| "closed" | | [data-highlighted] | Present when highlighted | | [data-disabled] | Present when disabled |

SubContent

The component that pops out when a submenu is open. Must be rendered inside Menubar.Sub.

| Prop | Type | Default | | --- | --- | --- | | asChild<br><br>Prop description | boolean | false | | loop<br><br>Prop description | boolean | false | | onEscapeKeyDown<br><br>Prop description | function<br><br>See full type | No default value | | onPointerDownOutside<br><br>Prop description | function<br><br>See full type | No default value | | onFocusOutside<br><br>Prop description | function<br><br>See full type | No default value | | onInteractOutside<br><br>Prop description | function<br><br>See full type | No default value | | forceMount<br><br>Prop description | boolean | No default value | | sideOffset<br><br>Prop description | number | 0 | | alignOffset<br><br>Prop description | number | 0 | | avoidCollisions<br><br>Prop description | boolean | true | | collisionBoundary<br><br>Prop description | Boundary<br><br>See full type | [] | | collisionPadding<br><br>Prop description | number \| Padding<br><br>See full type | 0 | | arrowPadding<br><br>Prop description | number | 0 | | sticky<br><br>Prop description | enum<br><br>See full type | "partial" | | hideWhenDetached<br><br>Prop description | boolean | false |

| Data attribute | Values | | --- | --- | | [data-state] | "open" \| "closed" | | [data-side] | "left" \| "right" \| "bottom" \| "top" | | [data-align] | "start" \| "end" \| "center" | | [data-orientation] | "vertical" \| "horizontal" |

| CSS Variable | Description | | --- | --- | | --radix-menubar-content-transform-origin | The transform-origin computed from the content and arrow positions/offsets | | --radix-menubar-content-available-width | The remaining width between the trigger and the boundary edge | | --radix-menubar-content-available-height | The remaining height between the trigger and the boundary edge | | --radix-menubar-trigger-width | The width of the trigger | | --radix-menubar-trigger-height | The height of the trigger |

Examples


With submenus

You can create submenus by using Menubar.Sub in combination with its parts.

<Menubar.Root>
	<Menubar.Menu>
		<Menubar.Trigger>…</Menubar.Trigger>
		<Menubar.Portal>
			<Menubar.Content>
				<Menubar.Item>…</Menubar.Item>
				<Menubar.Item>…</Menubar.Item>
				<Menubar.Separator />
				<Menubar.Sub>
					<Menubar.SubTrigger>Sub menu →</Menubar.SubTrigger>
					<Menubar.Portal>
						<Menubar.SubContent>
							<Menubar.Item>Sub menu item</Menubar.Item>
							<Menubar.Item>Sub menu item</Menubar.Item>
							<Menubar.Arrow />
						</Menubar.SubContent>
					</Menubar.Portal>
				</Menubar.Sub>
				<Menubar.Separator />
				<Menubar.Item>…</Menubar.Item>
			</Menubar.Content>
		</Menubar.Portal>
	</Menubar.Menu>
</Menubar.Root>

With disabled items

You can add special styles to disabled items via the data-disabled attribute.

// index.jsx
import { Menubar } from "radix-ui";
import "./styles.css";

export default () => (
	<Menubar.Root>
		<Menubar.Menu>
			<Menubar.Trigger>…</Menubar.Trigger>
			<Menubar.Portal>
				<Menubar.Content>
					<Menubar.Item className="MenubarItem" disabled>
						…
					</Menubar.Item>
					<Menubar.Item className="MenubarItem">…</Menubar.Item>
				</Menubar.Content>
			</Menubar.Portal>
		</Menubar.Menu>
	</Menubar.Root>
);


/* styles.css */
.MenubarItem[data-disabled] {
	color: gainsboro;
}

With separators

Use the Separator part to add a separator between items.

<Menubar.Root>
	<Menubar.Menu>
		<Menubar.Trigger>…</Menubar.Trigger>
		<Menubar.Portal>
			<Menubar.Content>
				<Menubar.Item>…</Menubar.Item>
				<Menubar.Separator />
				<Menubar.Item>…</Menubar.Item>
				<Menubar.Separator />
				<Menubar.Item>…</Menubar.Item>
			</Menubar.Content>
		</Menubar.Portal>
	</Menubar.Menu>
</Menubar.Root>

With labels

Use the Label part to help label a section.

<Menubar.Root>
	<Menubar.Menu>
		<Menubar.Trigger>…</Menubar.Trigger>
		<Menubar.Portal>
			<Menubar.Content>
				<Menubar.Label>Label</Menubar.Label>
				<Menubar.Item>…</Menubar.Item>
				<Menubar.Item>…</Menubar.Item>
				<Menubar.Item>…</Menubar.Item>
			</Menubar.Content>
		</Menubar.Portal>
	</Menubar.Menu>
</Menubar.Root>

With checkbox items

Use the CheckboxItem part to add an item that can be checked.

import * as React from "react";
import { CheckIcon } from "@radix-ui/react-icons";
import { Menubar } from "radix-ui";

export default () => {
	const [checked, setChecked] = React.useState(true);

	return (
		<Menubar.Root>
			<Menubar.Menu>
				<Menubar.Trigger>…</Menubar.Trigger>
				<Menubar.Portal>
					<Menubar.Content>
						<Menubar.Item>…</Menubar.Item>
						<Menubar.Item>…</Menubar.Item>
						<Menubar.Separator />
						<Menubar.CheckboxItem
							checked={checked}
							onCheckedChange={setChecked}
						>
							<Menubar.ItemIndicator>
								<CheckIcon />
							</Menubar.ItemIndicator>
							Checkbox item
						</Menubar.CheckboxItem>
					</Menubar.Content>
				</Menubar.Portal>
			</Menubar.Menu>
		</Menubar.Root>
	);
};

With radio items

Use the RadioGroup and RadioItem parts to add an item that can be checked amongst others.

import * as React from "react";
import { CheckIcon } from "@radix-ui/react-icons";
import { Menubar } from "radix-ui";

export default () => {
	const [color, setColor] = React.useState("blue");

	return (
		<Menubar.Root>
			<Menubar.Menu>
				<Menubar.Trigger>…</Menubar.Trigger>
				<Menubar.Portal>
					<Menubar.Content>
						<Menubar.RadioGroup value={color} onValueChange={setColor}>
							<Menubar.RadioItem value="red">
								<Menubar.ItemIndicator>
									<CheckIcon />
								</Menubar.ItemIndicator>
								Red
							</Menubar.RadioItem>
							<Menubar.RadioItem value="blue">
								<Menubar.ItemIndicator>
									<CheckIcon />
								</Menubar.ItemIndicator>
								Blue
							</Menubar.RadioItem>
						</Menubar.RadioGroup>
					</Menubar.Content>
				</Menubar.Portal>
			</Menubar.Menu>
		</Menubar.Root>
	);
};

With complex items

You can add extra decorative elements in the Item parts, such as images.

import { Menubar } from "radix-ui";

export default () => (
	<Menubar.Root>
		<Menubar.Menu>
			<Menubar.Trigger>…</Menubar.Trigger>
			<Menubar.Portal>
				<Menubar.Content>
					<Menubar.Item>
						<img src="…" />
						Adolfo Hess
					</Menubar.Item>
					<Menubar.Item>
						<img src="…" />
						Miyah Myles
					</Menubar.Item>
				</Menubar.Content>
			</Menubar.Portal>
		</Menubar.Menu>
	</Menubar.Root>
);

Constrain the content/sub-content size

You may want to constrain the width of the content (or sub-content) so that it matches the trigger (or sub-trigger) width. You may also want to constrain its height to not exceed the viewport.

We expose several CSS custom properties such as --radix-menubar-trigger-width and --radix-menubar-content-available-height to support this. Use them to constrain the content dimensions.

// index.jsx
import { Menubar } from "radix-ui";
import "./styles.css";

export default () => (
	<Menubar.Root>
		<Menubar.Trigger>…</Menubar.Trigger>
		<Menubar.Portal>
			<Menubar.Content className="MenubarContent" sideOffset={5}>
				…
			</Menubar.Content>
		</Menubar.Portal>
	</Menubar.Root>
);


/* styles.css */
.MenubarContent {
	width: var(--radix-menubar-trigger-width);
	max-height: var(--radix-menubar-content-available-height);
}

Origin-aware animations

We expose a CSS custom property --radix-menubar-content-transform-origin. Use it to animate the content from its computed origin based on side, sideOffset, align, alignOffset and any collisions.

// index.jsx
import { Menubar } from "radix-ui";
import "./styles.css";

export default () => (
	<Menubar.Root>
		<Menubar.Menu>
			<Menubar.Trigger>…</Menubar.Trigger>
			<Menubar.Portal>
				<Menubar.Content className="MenubarContent">…</Menubar.Content>
			</Menubar.Portal>
		</Menubar.Menu>
	</Menubar.Root>
);


/* styles.css */
.MenubarContent {
	transform-origin: var(--radix-menubar-content-transform-origin);
	animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
	from {
		opacity: 0;
		transform: scale(0);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

Collision-aware animations

We expose data-side and data-align attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations.

// index.jsx
import { Menubar } from "radix-ui";
import "./styles.css";

export default () => (
	<Menubar.Root>
		<Menubar.Menu>
			<Menubar.Trigger>…</Menubar.Trigger>
			<Menubar.Portal>
				<Menubar.Content className="MenubarContent">…</Menubar.Content>
			</Menubar.Portal>
		</Menubar.Menu>
	</Menubar.Root>
);


/* styles.css */
.MenubarContent {
	animation-duration: 0.6s;
	animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}
.MenubarContent[data-side="top"] {
	animation-name: slideUp;
}
.MenubarContent[data-side="bottom"] {
	animation-name: slideDown;
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

Accessibility


Adheres to the Menu Button WAI-ARIA design pattern and uses roving tabindex to manage focus movement among menu items.

Keyboard Interactions

| Key | Description | | --- | --- | | Space | When focus is on Menubar.Trigger, opens the menubar and focuses the first item. <br>When focus is on an item, activates the focused item. | | Enter | When focus is on Menubar.Trigger, opens the associated menu. <br>When focus is on an item, activates the focused item. | | ArrowDown | When focus is on Menubar.Trigger, opens the associated menu. <br>When focus is on an item, moves focus to the next item. | | ArrowUp | When focus is on an item, moves focus to the previous item. | | ArrowRightArrowLeft | When focus is on a Menubar.Trigger, moves focus to the next or previous item. <br>When focus is on a Menubar.SubTrigger, opens or closes the submenu depending on reading direction. <br>When focus is within a Menubar.Content, opens the next menu in the menubar. | | Esc | Closes the currently open menu and moves focus to its Menubar.Trigger. |

PreviousLabel

NextNavigation Menu

Edit this page on GitHub.