Navigation

Menubar

A row of menus, like a desktop app’s File, Edit and View: for tools with many commands.

Installation

npx sinaui add menubar

Examples

An editor

Open a menu, then move along the bar with the pointer or the arrow keys: the next menu opens without another click.

Nothing chosen yet.

<script lang="ts">
	import Kbd from '#lib/ui/Kbd.svelte';
	import * as Menubar from '#lib/ui/menubar/index.js';

	let last = $state('Nothing chosen yet.');
	const did = (what: string) => () => (last = what);
</script>

<div class="stack">
	<Menubar.Root label="Manuscript editor">
		<Menubar.Menu label="File">
			<Menubar.Item onselect={did('Started a new page.')}>
				New page <span class="keys"><Kbd keys={['mod', 'N']} /></span>
			</Menubar.Item>
			<Menubar.Item onselect={did('Opened the catalog.')}>Open from the catalog…</Menubar.Item>
			<Menubar.Item onselect={did('Saved the page.')}>
				Save <span class="keys"><Kbd keys={['mod', 'S']} /></span>
			</Menubar.Item>
			<Menubar.Separator />
			<Menubar.Item onselect={did('Sent to the copyists.')}>Send to the copyists</Menubar.Item>
		</Menubar.Menu>
		<Menubar.Menu label="Edit">
			<Menubar.Item onselect={did('Undid the last change.')}>
				Undo <span class="keys"><Kbd keys={['mod', 'Z']} /></span>
			</Menubar.Item>
			<Menubar.Item onselect={did('Redid the change.')}>
				Redo <span class="keys"><Kbd keys={['mod', 'shift', 'Z']} /></span>
			</Menubar.Item>
			<Menubar.Separator />
			<Menubar.Item onselect={did('Added a note in the margin.')}>Add a margin note</Menubar.Item>
			<Menubar.Item disabled>Remove the illumination</Menubar.Item>
		</Menubar.Menu>
		<Menubar.Menu label="View">
			<Menubar.Item onselect={did('Zoomed in.')}>
				Zoom in <span class="keys"><Kbd keys={['mod', '+']} /></span>
			</Menubar.Item>
			<Menubar.Item onselect={did('Zoomed out.')}>
				Zoom out <span class="keys"><Kbd keys={['mod', '-']} /></span>
			</Menubar.Item>
			<Menubar.Item onselect={did('Showing the facing page.')}>Show the facing page</Menubar.Item>
		</Menubar.Menu>
		<Menubar.Menu label="Help">
			<Menubar.Item onselect={did('Opened the keyboard guide.')}>Keyboard guide</Menubar.Item>
			<Menubar.Item href="#accessibility">About the menu bar</Menubar.Item>
		</Menubar.Menu>
	</Menubar.Root>
	<p role="status">{last}</p>
</div>

<style>
	.stack {
		display: grid;
		gap: 1rem;
	}
	.keys {
		margin-inline-start: auto;
		padding-inline-start: 1.5rem;
	}
	p {
		margin: 0;
		color: var(--ui-muted);
		font-size: 0.875rem;
	}
</style>

Props

Menubar.Root

PropTypeDefault
labelstring (required)
childrenMenubar.Menu elements

Menubar.Menu

PropTypeDefault
labelstring (required)
childrenMenubar.Item, Menubar.Separator

Items are the Dropdown’s: onselect, href, disabled, variant.

Keyboard

KeyDoes
TabInto the bar (one stop for the whole bar), and out again
Arrow Left / RightThe previous or next menu; if one is open, that one opens
Arrow Down, Enter, SpaceOpen the menu on its first item
Arrow UpOpen the menu on its last item
Home / EndThe first or last menu
EscapeClose the menu, back to its name

Accessibility

  • A menu bar of menu items, each owning its menu, as desktop screen readers expect.
  • One Tab stop for the whole bar; the arrow keys do the rest, and remember where you were.
  • Shortcuts shown in items are read by name (“Command+S”).
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme