TopbarMenu
A topbar circle (mock .circle) or pill that opens a panel under it: the console's Help menu, the PR portal's "New" menu, the user menu. A disclosure, not an ARIA menu: opening it (click, Enter, Space or ArrowDown) puts focus on its first item; Tab moves through the panel, ArrowDown/ArrowUp too (wrapping, and from the trigger into the panel while it is open); Escape closes it and returns focus to the trigger; a click outside, or focus leaving the menu, closes it.
import { TopbarMenu } from '@ergasti/bricks';Examples
Menus
A button that opens a menu: Arrow keys move, Enter picks, Escape closes and returns focus. Items run onSelect, or link with href; keepOpen leaves the menu open (copy link).
Code
import { Icon, TopbarMenu, UserMenu, Avatar } from '@ergasti/bricks';
function Menus() {
return (
<div style={{ display: 'flex', gap: 12, justifyContent: 'flex-end', flexWrap: 'wrap' }}>
<TopbarMenu label="Help" trigger={<Icon name="help" />} items={[{ id: 'copy', label: 'Copy link to this view', keepOpen: true }, { id: 'contact', label: 'Contact TRNDR', href: 'https://example.com', external: true }]} />
<TopbarMenu label="New" variant="pill" trigger={<><Icon name="motivation" /> New</>} items={[{ id: 'ch', label: 'Challenge', sub: 'Target or leaderboard', icon: 'motivation' }, { id: 'ap', label: 'Affiliate program', sub: 'For a brand without one', icon: 'coupons' }]} />
<UserMenu name="Nour Hassan" detail="HushUp" avatar={<Avatar name="Nour Hassan" seed={3} size="sm" />} logout={<button type="button">Sign out</button>} />
</div>
);
}Props
Prop
Type
Design guidance
How the BRICKS design system uses TopbarMenu. Written in docs/content/components/TopbarMenu.md; the props above are read from the code, which wins where the two disagree.
A top-bar button that opens a small panel of items under it: a 44px circle (Help) or a pill (the PR Portal's raspberry "+ New"); use it in AppHeader's actions for help, create and account menus.
It covers the mocks' .circle help button and the PR mock's "+ New" menu (.newwrap: Challenge "Target or leaderboard", Affiliate program "For a brand without one"); UserMenu is built on it. It is a disclosure, not an ARIA menu: opening it puts focus on the first item, Tab and the arrows move through the panel, Escape closes it and returns focus to the trigger, and a click outside or focus leaving closes it.
Anatomy
- Trigger:
.kit-shell-circle(44px round, icon) or.kit-shell-pill-btn(44px pill;tone="rasp"filled raspberry); optional raspberry dot (.kit-shell-dotr). - Panel (
.kit-shell-pop,role="region"named bylabel): 300px, radius 18, under the trigger, end-aligned. - Header (optional): free content (the user's name and role).
- Items (
.kit-shell-pop-item--row): optional 34px raspberry-50 icon tile, a 600 label, a mutedsub;<a>withhref(new tab withexternal) or<button>. - Footer (
.kit-shell-pop-foot, after a rule): sign out.
Variants
| Prop | Value | Look | Use when |
|---|---|---|---|
variant | 'circle' (default) | 44px round icon button | Help, settings. |
variant | 'pill' | Pill with icon/avatar and words | "New", the user. |
tone | 'default' | White pill | User menu. |
tone | 'rasp' | Filled raspberry pill | The PR "+ New" (B21). |
dot | true | Raspberry dot on the circle | Something new or unread. |
States
| State | How |
|---|---|
| Closed | aria-expanded="false". |
| Open | click, Enter or Space (focus on the first item), ArrowDown (first item) or ArrowUp (opens; with the menu open, ArrowDown / ArrowUp move to its first / last item); onOpen called. |
| Item kept open | keepOpen (an inline status follows, "Link copied"). |
| Hover / focus | Trigger border darkens / raspberry focus ring; items --soft hover, inset focus ring. |
Types
TopbarMenuItem (items): { id, label, sub?, icon?, href?, external?, onSelect?, keepOpen? }.
Usage
// Brand dashboard help
<TopbarMenu
label="Help"
trigger={<Icon name="help" />}
items={[
{ id: 'copy', label: 'Copy link to this view', onSelect: copyLink, keepOpen: true },
{ id: 'contact', label: 'Contact TRNDR', href: 'https://wa.me/…', external: true },
]}
/>// PR Portal "+ New", after the bell
<AppHeader
title="Challenges"
search={search}
actions={<>
<NotificationsMenu items={notifications} onOpenItem={openNotification} onSeeAll={seeAllNotifications} />
<TopbarMenu label="New" variant="pill" tone="rasp" trigger={<><Icon name="plus" /> New</>}
items={[
{ id: 'ch', label: 'Challenge', sub: 'Target or leaderboard', icon: 'motivation', onSelect: newChallenge },
{ id: 'ap', label: 'Affiliate program', sub: 'For a brand without one', icon: 'coupons', onSelect: newProgram },
]} />
</>}
/>Where it appears
- Brand › every screen › top bar › Help circle. Screens:
Brand*. - PR Portal › every screen › top bar › "+ New" (Challenge / Affiliate program; only Gift on the gifts pages). Screen:
Pr*, PR · Home (open). - Inside
UserMenu.
Guidelines
Do
- Keep 2–5 items; add a
subwhen the label alone is ambiguous. - Use
keepOpenonly when the item shows its result inside the panel.
Don't
- Don't nest menus.
- Don't use it for notifications (use
NotificationsMenu) or for row actions (RowActions).
RTL and Arabic
- The panel aligns to the trigger's end edge (left in Arabic); icon tiles sit on the right.
Tokens
--card, --line, --ink, --ink-3, --soft, --rasp, --rasp-d, --rasp-50 (icon tile), --focus-ring, --focus-ring-inset, --color-control-border-hover.
Accessibility
- Disclosure: the trigger is a
<button>witharia-expanded/aria-controls; circle triggers are named byaria-label, pill triggers by their words. - The panel is a labelled
region; items are real links and buttons, so Tab works; ArrowUp/Down wrap; Escape returns focus to the trigger; leaving focus closes it. - External links open with
rel="noopener noreferrer".
Found in the source
- Roles in the markup:
region. - ARIA attributes set:
aria-label,aria-expanded,aria-controls,aria-hidden. - Keys the code handles: ArrowDown.
- It moves focus in code.
- Its tests cover: “keyboard: ArrowDown on the trigger opens it on the first item, arrows move (wrapping), Escape closes and returns focus”; “B8: opening by Enter or click puts focus on the first item; the arrows reach the panel from the trigger while open”; “B8: Tab past the last item (focus leaving the menu) closes it, and focus goes on”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
UserMenu: the account pill built on it.NotificationsMenu: the bell.RowActions: per-row actions with a "⋯" menu.
See also: useLanguage · Icon · Avatar · AppHeader · HeaderSearch · LanguageToggle · LogoutButton
Source
src/shell/TopbarMenu.tsx (line 52) on GitHub.