Weftv0.4.0
GitHubFigma
Blade AI
Display & Navigation · Menustable

Menu

A dark action menu opened from a button or avatar, with optional profile header, separators and destructive items.

Preview

#preview

Switch placement, alignment, header and items. Click the trigger or press Arrow Down to open. Show code opens the React and CSS below.

placement bottom · align start · header none
menu-example.tsx
import { Menu } from "@blade-ai/weft/components/menu";
import { Button } from "@blade-ai/weft/components/button";

export function AccountMenu() {
  return (
    <Menu
      trigger={<Button variant="secondary" size="small">Account</Button>}
      items={[
        { label: "Profile", onSelect: openProfile },
        { label: "Settings", onSelect: openSettings },
        { type: "separator" },
        { label: "Log out", intent: "negative", onSelect: logOut },
      ]}
    />
  );
}

All states

#all-states

Every item state and layout, shown as the open panel inline. The live menu is portal-free but anchored to its trigger, so these tiles are static renders of the same tokens.

Menu · 9 variants · static open panel
Profile
Settings
Billing
Default
Profile
Settings
Billing
Hover item
Profile
Settings
Billing
Focus-visible item
Profile
Billing
Settings
Disabled item
Settings
Log out
Negative item
Settings
Log out
Negative · hover
Workspace
Search
Invite people
With leading icons
Profile
Settings
Help
With separator
Profile
Settings
Log out
With profile header

Props

#props

Menu takes a trigger element and an items array. Items and separators share one list.

Menu
Prop
Type
Default
Description
trigger *
ReactElement
—
The element that opens the menu: a button or the avatar. Must be a single focusable element. It gets aria-haspopup, aria-expanded, aria-controls and the toggle click.
items *
MenuEntry[]
—
Items and separators in order.
header
MenuHeader
—
Optional profile header above the first item: name, email, initials.
accessibilityLabel
string
—
Accessible name of the menu when the trigger has no text.
align
"start" | "end"
"start"
Which trigger edge the menu lines up with.
placement
"bottom" | "top"
"bottom"
Open below or above the trigger.
width
number
250
Menu width in px.
className
string
—
Extra classes on the menu panel.
MenuItem
Prop
Type
Default
Description
type
"item"
"item"
Discriminant. Omit for an item.
label *
string
—
Visible text; also the typeahead key.
icon
IconComponent
—
Optional 16px leading icon. Decorative.
intent
"default" | "negative"
"default"
negative tints the item red (Log out, Delete).
isDisabled
boolean
false
Dims the item, skips it in keyboard navigation and ignores selection.
onSelect *
() => void
—
Fires on click, Enter and Space; the menu then closes and focus returns to the trigger.
MenuSeparator and MenuHeader
Prop
Type
Default
Description
{ type: "separator" }
MenuSeparator
—
A 1px divider between groups of items.
header.name *
string
—
Shown bold.
header.email
string
—
Shown muted under the name.
header.initials
string
initials of name
Avatar letters.

Usage

#usage

Short rules for using menu.

Do
Use verbs for labels: Edit profile, Download report.
Group related actions and split groups with a separator.
Put destructive actions last, with intent negative.
Give an icon-only trigger an accessibilityLabel.
Don't
Don't use a menu for navigation between pages; use Side Nav or Tabs.
Don't nest menus inside menus.
Don't hide the only way to complete a task in a menu.
Don't make every item negative; reserve it for one action.

Accessibility

#accessibility

WAI-ARIA menu button pattern. Focus moves to the first item on open and back to the trigger on close.

Keyboard
Key
Action
Enter / Space
On the trigger, toggles the menu. On an item, selects it and closes.
Arrow Down / Up
On the trigger, opens the menu. Inside, moves to the next or previous item and wraps.
Home / End
Moves to the first or last item.
Type a letter
Typeahead: jumps to the next item whose label starts with the typed text.
Esc
Closes the menu and returns focus to the trigger.
Tab
Closes the menu and moves on.
ARIA
Element
Role / attribute
When
Trigger
aria-haspopup="menu", aria-expanded, aria-controls
Always; aria-controls only while open.
Panel
role="menu", aria-label
While open. aria-label comes from accessibilityLabel.
Item
role="menuitem", tabIndex -1, aria-disabled
Roving focus; aria-disabled when isDisabled.
Divider
role="separator"
Between groups and under the header.
Icon and avatar
aria-hidden="true"
Always; decorative.