Skip to content
kerfjsGitHub

Menu

A short list of actions that opens from a button.

SourcePackage @kerf-js/veneer

Preview

tsx
import { Menu } from '@kerf-js/veneer'export function Basic() {  return (  <Menu    label="Actions"    items={[      { label: 'Rename', icon: 'pencil', shortcut: '⌘R' },      {        label: 'Duplicate',        icon: 'copy',        shortcut: '⌘D',      },      { separator: true },      {        label: 'Delete',        icon: 'trash',        tone: 'critical',      },    ]}  />  )}

Installation

npm install @kerf-js/veneer

Usage

tsx
import { Menu } from '@kerf-js/veneer'

Placement

Use side to pick where it opens.

Alignment

Use align to line it up with the button.

Groups

A group entry names what follows.

Trigger styles

trigger takes any Button prop.

A row's actions

Use items to list a row's actions, and trigger to make the button quiet enough to sit in a row.

When to use

Use it for

  • Several actions on one thing, and not much room

Reach for something else

Accessibility

Enter
Opens, or picks the highlighted item
↑↓
Moves through the items
HomeEnd
Jumps to the first or last
Esc
Closes and returns focus
Aletter
Jumps to the next item starting with it

Theming

Restyle it app-wide from veneer() in your kerf config. Every key takes colour, spacing, size, radius, shadow, type and motion; its own keys are listed. A state nests inside: hover: { bg: 'ink' }. Text on a fill you set is contrast-checked at build. How theming works

KeyOwn keysStates
parts.popover—none
ts
veneer({  colors: { brand: '#e8590c', ink: '#1b1b1f' },  parts: {    popover: { radius: 12, shadow: 'lg' },  },})

API Reference

PropTypeDefaultDescription
labelunknown—The trigger's text.
itemsMenuEntry[]—The entries: an action, { separator: true } or { group }.
triggerButtonProps—Button props for the trigger.
sideSide'bottom'Which side it opens on.
alignAlign'start'How it lines up with the trigger.

Parts

Every element carries a stable name, so you can style it from your own CSS: [data-scope="menu"] [data-part="content"]

contentshuttleseparatorgroup-labelitem

RelatedButtonPopoverCommand palette