shadcn.io is not affiliated with official shadcn/ui
Installation
bunx --bun shadcn@latest add https://kit.dev/r/base/menubar.jsonnpx shadcn@latest add https://kit.dev/r/base/menubar.jsonpnpm dlx shadcn@latest add https://kit.dev/r/base/menubar.jsonyarn shadcn@latest add https://kit.dev/r/base/menubar.jsonThis component depends on Dropdown Menu. Install it first if you haven't already.
Install the following dependencies:
bun add @base-ui/react lucide-reactnpm install @base-ui/react lucide-reactpnpm add @base-ui/react lucide-reactyarn add @base-ui/react lucide-reactCopy and paste the following code into your project.
"use client";
import { Menu as MenuPrimitive } from "@base-ui/react/menu";
import { Menubar as MenubarPrimitive } from "@base-ui/react/menubar";
import { CheckIcon } from "lucide-react";
import type React from "react";
import { cn } from "@/lib/utils";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuPortal,
DropdownMenuRadioGroup,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuSub,Update the import paths to match your project setup.
Anatomy
Menubar
├── MenubarMenu
│ ├── MenubarTrigger
│ └── MenubarContent
│ ├── MenubarGroup
│ │ ├── MenubarLabel
│ │ ├── MenubarItem
│ │ └── MenubarItem
│ ├── MenubarSeparator
│ ├── MenubarGroup
│ │ ├── MenubarCheckboxItem
│ │ └── MenubarCheckboxItem
│ ├── MenubarRadioGroup
│ │ ├── MenubarRadioItem
│ │ └── MenubarRadioItem
│ └── MenubarSub
│ ├── MenubarSubTrigger
│ └── MenubarSubContent
│ └── MenubarItem
└── MenubarMenu
├── MenubarTrigger
└── MenubarContentUsage
import {
Menubar,
MenubarContent,
MenubarGroup,
MenubarItem,
MenubarMenu,
MenubarSeparator,
MenubarShortcut,
MenubarTrigger,
} from "@/components/ui/menubar";<Menubar>
<MenubarMenu>
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent>
<MenubarGroup>
<MenubarItem value="new-tab">
New Tab <MenubarShortcut>⌘T</MenubarShortcut>
</MenubarItem>
<MenubarItem value="new-window">New Window</MenubarItem>
</MenubarGroup>
<MenubarSeparator />
<MenubarGroup>
<MenubarItem value="share">Share</MenubarItem>
<MenubarItem value="print">Print</MenubarItem>
</MenubarGroup>
</MenubarContent>
</MenubarMenu>
</Menubar>Accessibility
| Key | Description |
|---|---|
Enter | Activate the focused control. |
Space | Activate the focused control. |
ArrowDown | Move down. |
ArrowUp | Move up. |
ArrowLeft | Move left. |
ArrowRight | Move right. |
Home | Go to the start. |
End | Go to the end. |
Demos
Checkbox
Use MenubarCheckboxItem for toggleable options.
Radio
Use MenubarRadioGroup and MenubarRadioItem for single-select options.
Submenu
Use MenubarSub, MenubarSubTrigger, and MenubarSubContent for nested menus.
Icons
Combine icons with labels for quick scanning.
Rtl
Right-to-left menubar. See the RTL configuration guide for document direction.
API Reference
Menubar
PropType
AttributeType
MenubarMenu
PropType
AttributeType
MenubarGroup
PropType
AttributeType
MenubarPortal
PropType
AttributeType
MenubarTrigger
PropType
children?React.ReactNodeAttributeType
MenubarContent
PropType
children?React.ReactNodeid?stringAttributeType
MenubarItem
PropType
id?stringAttributeType
MenubarCheckboxItem
div
PropType
id?stringAttributeType
MenubarRadioGroup
PropType
AttributeType
MenubarRadioItem
div
PropType
id?stringAttributeType
MenubarLabel
PropType
AttributeType
MenubarSeparator
PropType
AttributeType
MenubarShortcut
PropType
AttributeType
MenubarSub
PropType
AttributeType
MenubarSubTrigger
PropType
id?stringAttributeType
MenubarSubContent
PropType
children?React.ReactNodeid?stringAttributeType