Menubar
A desktop-application-style horizontal menu bar. It is a compound family composed over the shared Dropdown Panel base, so hover-to-switch, click latching, nested submenus, outside-press dismissal and the in-menu keyboard model come from the web component rather than from 495 lines of ported machinery.
Accessibility is the disclosure pattern, not role="menubar". The component underneath is disclosure-style by design and does not implement bar-level roving, so claiming those roles would promise a keyboard model that is not there. Tab moves between triggers; inside an open menu the arrows, Home/End and Escape apply.
Last press: nothing yet
Installation
Copy the family into your app. It pulls the shared dropdown-panel base along with it:
puzzle add piece menubar
That base has a runtime dependency — the web component it wraps:
npm install @magic-spells/dropdown-panel
Then merge its stylesheets into your app's style entry. The first is required; the second adds the entrance effects and the drawn trigger arrow:
/* app/styles/styles.css */ @import "tailwindcss"; @import "@magic-spells/dropdown-panel/css" layer(components); /* required */ @import "@magic-spells/dropdown-panel/css/effects" layer(components); /* optional */
Requires the pieces.css tokens merged into your app styles (see Introduction).
Usage
import Menubar from '@/components/ui/Menubar';
<Menubar label="Editor menu">
<Menubar.Menu>
<Menubar.Trigger>File</Menubar.Trigger>
<Menubar.Content>
<Menubar.Item value="new" @press={ run }>
New file<Menubar.Shortcut>⌘N</Menubar.Shortcut>
</Menubar.Item>
<Menubar.Separator />
<Menubar.Menu>
<Menubar.Trigger variant="item">Export as</Menubar.Trigger>
<Menubar.Content opens="right">
<Menubar.Item value="export-pdf" @press={ run }>PDF</Menubar.Item>
</Menubar.Content>
</Menubar.Menu>
</Menubar.Content>
</Menubar.Menu>
</Menubar>A submenu is a Menu nested inside a Content, with the inner Content set to opens="right". Pressing any row closes the whole bar — a submenu and its parent collapse together — and returns focus to the trigger.
Item is a real button and Link is a real link; they are separate members rather than one component with an href, because a template may declare only one children marker and a two-branch root cannot compile.
Keyboard
All of it lives in the web component; this family adds no key handling of its own.
TabMoves between triggers. There is no Left/Right roving across the bar — the component is a disclosure, and the piece does not claim menubar roles it cannot honour.Enter / SpaceOn a trigger: toggle its menu. On a row: activate it.ArrowDown / ArrowUpOn a closed trigger: open and focus the first (or last) row. Inside an open menu: move row focus, wrapping at the ends.Home / EndInside an open menu: first / last row.ArrowRight / ArrowLeftOpen an opens="right" submenu, and close it again returning focus to its trigger.EscapeClose one level and focus its trigger. Only the innermost open menu answers.Reference
Menubar
The bar — a plain <nav> with an aria-label, and the `relative` a wide panel positions against.
labelaria-label for the bar. Defaults to "Menu bar".classMerged onto the bar, after its chrome.Menubar.Menu
One menu: a trigger and the panel it opens. Nest one inside a Content for a submenu.
trigger'hover' | 'click' | 'both' (default) — hover opens, a click latches.arrow'none' (default here) | 'flip' | 'static' — for a trigger that carries an arrow hook.openOptional-controlled and edge-triggered, forwarded to the base.effect'fade' | 'slide' | 'scale' | 'blur' | 'swing'. Needs the effects stylesheet.classMerged onto the host, after the load-bearing `block`.@show / @hideFired when THIS menu opens or closes; a nested submenu's events are filtered out.Menubar.Trigger
A top label, or the row that opens a submenu. Keep its content non-interactive — it is the control.
variant'bar' (default) for a top label, 'item' for an in-panel submenu row.classMerged onto the trigger, after the variant chrome.Menubar.Content
The panel a menu drops.
align'start' (default) | 'end' for a menu near the right edge.opens'down' (default) | 'right' for a submenu.wideA full-width panel spanning the bar.effect'fade' | 'slide' | 'scale' | 'blur' | 'swing'. Needs the effects stylesheet.classMerged onto the panel. Merging is not precedence: use the ! suffix (mt-1!) to override a default. Never overflow-hidden.Menubar.Item
An action row — a real button. Activating it fires @press and closes the whole bar.
valuePassed to @press.variant'default' | 'danger' for a destructive tint.disabledGreys the row out and swallows the press.classMerged onto the row, after the chrome.@pressValue-first: press(value). Named apart from `value` — a callback whose name equals a prop name collides in the same props object.Menubar.Link
Item's twin as a real <a>, for a row that navigates.
hrefThe destination.valuePassed to @press.variant'default' | 'danger'.disabledaria-disabled plus the muted treatment; the press is swallowed.@pressA hook fired before navigation — it cannot cancel the visit.Menubar.Separator · Label · Shortcut
Plain markup: a hairline with role="separator", a non-interactive group heading, and the <kbd> hint an Item pushes to its trailing edge.
classEach takes a class merged onto its element.