Keyframery

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.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/menubar

This 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
        └── MenuItem

Examples

An app's menu bar

Once one menu is open, moving the pointer or the arrow keys along the bar opens the next.

Motion

MoveWhat you see
GlideA highlight glides along the bar from one menu to the next.
UnfoldEach menu unfolds from its title.
CascadeRows 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.

VariableWhat it changesDefault
--menubar-surfaceMenu sheets--popover
--menubar-inkSheet and trigger text--popover-foreground; --foreground for triggers
--menubar-highlightBar and row highlights--accent
--menubar-dangerDestructive text and highlight--destructive
--menubar-radiusSheet corners14px
--menubar-item-radiusRow and trigger corners8px
--menubar-heightTrigger height1.75rem
--menubar-gapBar trigger gap0.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.

Renders a <div>, and takes its props too.

Prop

Type

Prop

Type

Renders a <button>, and takes its props too.

Prop

Type

Renders a <div>, and takes its props too.

Prop

Type

Renders a <div>, and takes its props too.

Prop

Type

Renders a <div>, and takes its props too.

Prop

Type

Renders a <div>, and takes its props too.

Prop

Type

Renders a <span>, and takes its props too.

Prop

Type

Renders a <span>, and takes its props too.

Prop

Type

Prop

Type

Renders a <div>, and takes its props too.

Prop

Type

Renders a <div>, and takes its props too.

Prop

Type

Prop

Type

Renders a <div>, and takes its props too.

Prop

Type

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

KeyWhat it does
← →Moves between the bar's menus, and opens the next one if a menu is open.
↓Opens the focused menu.
EnterChooses the highlighted item.
EscapeCloses 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.

All components

On this page