mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 14:08:47 +00:00
76 lines
1.6 KiB
Plaintext
76 lines
1.6 KiB
Plaintext
---
|
|
title: Menubar
|
|
description: A visually persistent menu common in desktop applications that provides quick access to a consistent set of commands.
|
|
component: true
|
|
radix:
|
|
link: https://www.radix-ui.com/docs/primitives/components/menubar
|
|
api: https://www.radix-ui.com/docs/primitives/components/menubar#api-reference
|
|
---
|
|
|
|
<ComponentExample src="/components/examples/menubar/demo.tsx">
|
|
<MenubarDemo />
|
|
</ComponentExample>
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npx shadcn-ui add menubar
|
|
```
|
|
|
|
<Accordion type="single" collapsible>
|
|
<AccordionItem value="manual-installation">
|
|
<AccordionTrigger>Manual Installation</AccordionTrigger>
|
|
<AccordionContent>
|
|
|
|
1. Install the `@radix-ui/react-menubar` component from radix-ui:
|
|
|
|
```bash
|
|
npm install @radix-ui/react-menubar
|
|
```
|
|
|
|
2. Copy and paste the following code into your project.
|
|
|
|
<ComponentSource src="/components/ui/menubar.tsx" />
|
|
|
|
<Callout>
|
|
This is the `<Menubar />` primitive. You can place it in a file at
|
|
`components/ui/menubar.tsx`.
|
|
</Callout>
|
|
|
|
</AccordionContent>
|
|
|
|
</AccordionItem>
|
|
</Accordion>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import {
|
|
Menubar,
|
|
MenubarContent,
|
|
MenubarItem,
|
|
MenubarMenu,
|
|
MenubarSeparator,
|
|
MenubarShortcut,
|
|
MenubarTrigger,
|
|
} from "@/components/ui/menubar"
|
|
```
|
|
|
|
```tsx
|
|
<Menubar>
|
|
<MenubarMenu>
|
|
<MenubarTrigger>File</MenubarTrigger>
|
|
<MenubarContent>
|
|
<MenubarItem>
|
|
New Tab <MenubarShortcut>⌘T</MenubarShortcut>
|
|
</MenubarItem>
|
|
<MenubarItem>New Window</MenubarItem>
|
|
<MenubarSeparator />
|
|
<MenubarItem>Share</MenubarItem>
|
|
<MenubarSeparator />
|
|
<MenubarItem>Print</MenubarItem>
|
|
</MenubarContent>
|
|
</MenubarMenu>
|
|
</Menubar>
|
|
```
|