Menubar
A highlight glides along the bar from one menu to the next, and each menu unfolds from its title.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/menubarThis adds components/keyframery/menubar.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { Menu, Menubar, MenuContent, MenuItem, MenuTrigger } from "@/components/keyframery/menubar"
export default function Usage() {
return (
<Menubar aria-label="App">
<Menu>
<MenuTrigger>File</MenuTrigger>
<MenuContent>
<MenuItem value="new">New</MenuItem>
</MenuContent>
</Menu>
</Menubar>
)
}Anatomy
How the parts fit together:
Menubar
└── Menu
├── MenuTrigger
└── MenuContent
└── MenuItemExamples
An app's menu bar
Once one menu is open, moving the pointer or the arrow keys along the bar opens the next.
Motion
| Move | What you see |
|---|---|
| Glide | A highlight glides along the bar from one menu to the next. |
| Unfold | Each menu unfolds from its title. |
| Cascade | Rows arrive one after another. |
Timing and springiness follow the motion style you set. To change how fast this menubar moves, pass speed:
<Menubar speed="fast">
…
</Menubar>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--menubar-surface | Menu sheets | --popover |
--menubar-ink | Sheet and trigger text | --popover-foreground; --foreground for triggers |
--menubar-highlight | Bar and row highlights | --accent |
--menubar-danger | Destructive text and highlight | --destructive |
--menubar-radius | Sheet corners | 14px |
--menubar-item-radius | Row and trigger corners | 8px |
--menubar-height | Trigger height | 1.75rem |
--menubar-gap | Bar trigger gap | 0.125rem |
API reference
Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK menubar reference.
Menubar
Renders a <div>, and takes its props too.
Prop
Type
Menu
Prop
Type
MenuTrigger
Renders a <button>, and takes its props too.
Prop
Type
MenuContent
Renders a <div>, and takes its props too.
Prop
Type
MenuItem
Renders a <div>, and takes its props too.
Prop
Type
MenuCheckboxItem
Renders a <div>, and takes its props too.
Prop
Type
MenuContextTrigger
Renders a <div>, and takes its props too.
Prop
Type
MenuItemIcon
Renders a <span>, and takes its props too.
Prop
Type
MenuItemIndicator
Renders a <span>, and takes its props too.
Prop
Type
MenuItems
Prop
Type
MenuRadioGroup
Renders a <div>, and takes its props too.
Prop
Type
MenuRadioItem
Renders a <div>, and takes its props too.
Prop
Type
MenuSub
Prop
Type
MenuSubContent
Renders a <div>, and takes its props too.
Prop
Type
MenuSubTrigger
Renders a <div>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
MenuGroup: a<div>MenuGroupLabel: a<div>MenuSeparator: a<div>MenuShortcut: a<span>
Keyboard
| Key | What it does |
|---|---|
| ← → | Moves between the bar's menus, and opens the next one if a menu is open. |
| ↓ | Opens the focused menu. |
| Enter | Chooses the highlighted item. |
| Escape | Closes the menu. |
Accessibility
Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.
Swap the import
Already using UI SDK's menubar with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.
// Before
import { … } from "@ui-sdk/react/menubar"
// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/menubar"Questions
How does the animated Menubar for UI SDK move?
Glide: A highlight glides along the bar from one menu to the next. Unfold: Each menu unfolds from its title. Cascade: Rows arrive one after another.
Do I need Motion or Framer Motion for the animated Menubar?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
Can I keep my own styling and only take the motion?
Yes. Import from @/components/keyframery/primitives/menubar instead. It has the same parts and props as @ui-sdk/react/menubar and adds motion only.
What happens to the Menubar when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.