GitHubGitHub
← All components
Actions / component

Toolbar menu

A kebab menu that collapses secondary toolbar actions behind one trigger. Items self-register, so a menu whose entries are all permission-gated renders nothing at all.

DefaultHover openNo items

No action yet

<ToolbarMenu>  <ToolbarMenuItem onclick={importCsv}>Import CSV</ToolbarMenuItem>  <ToolbarMenuItem onclick={download}>Download CSV</ToolbarMenuItem></ToolbarMenu>

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { ToolbarMenu } from '@chanrg/4ui';<ToolbarMenu>  <ToolbarMenuItem onclick={importCsv}>Import CSV</ToolbarMenuItem>  <ToolbarMenuItem onclick={download}>Download CSV</ToolbarMenuItem></ToolbarMenu>

Composition

Use the following composition to build a toolbar menu:

ToolbarMenu
└── ToolbarMenuItem
    ├── icon (snippet)
    └── children

Gated items

Items self-register, so a menu whose entries are all permission-gated renders no trigger at all.

Every item is gated away, so no trigger renders at all

<!-- Every item is permission-gated away, so no trigger renders at all. --><ToolbarMenu>  {#if canImport}<ToolbarMenuItem onclick={importCsv}>Import CSV</ToolbarMenuItem>{/if}</ToolbarMenu>

API reference

Props

PropTypeDefaultDescription
labelstring'Actions'Names both the trigger and the panel.
childrenSnippetToolbarMenuItem rows.
item.icon / disabled / titleSnippet / boolean / stringPer-item leading glyph, gating, and a tooltip explaining why it is gated.
item.onclick(event) => voidActivation closes the menu without stealing focus from a modal it opens.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.

Accessibility

  • Arrow keys, Home and End roam the live menu items and Tab wraps inside the panel.
  • Escape closes and returns focus to the trigger.
  • The panel stays mounted while hidden, so an item that opened a dialog keeps its state.

Dependencies

Icon, portal action