Menubar
A row of menus like a desktop app's File, Edit and View, using the Dropdown Menu's items. Same markup and props in every style: switch the style in the header to see it change.
Basic
File, Edit and View menus with shortcuts. In HTML, add data-vin-menubar and include vinui.js once.
Options
Menus with items that turn on and off and a choice of one.
Installation
React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:
npx @vinish/ui add menubarimport { Menubar, MenubarMenu } from "@/components/vin/menubar";import Menubar, { MenubarMenu } from "@/components/vin/menubar.vue";import Menubar from "$lib/components/vin/menubar.svelte";
import MenubarMenu from "$lib/components/vin/menubar-menu.svelte";The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.
Plain HTML: the classes come with the style's stylesheet. This component also needs vinui.js for its keyboard and pointer behaviour.
API
From spec/menubar.json, which every framework version is tested against.
| Prop | Values | Default | In HTML |
|---|---|---|---|
labelName for the menubar, read by screen readers. | string | — | aria-label on .vin-menubar[role=menubar] |
MenubarMenuOne button in the bar and its menu. The items are Dropdown Menu's: DropdownMenuItem, CheckboxItem, RadioGroup, Label and Separator. | { label: string, children } | — | button.vin-menubar__trigger[role=menuitem][aria-haspopup=menu][popovertarget] + .vin-menu[popover][role=menu] |
Parts
| React, Vue, Svelte | HTML classes |
|---|---|
<Menubar><MenubarMenu> | .vin-menubar.vin-menubar__trigger |
Accessibility
- role="menubar" with a menuitem button for each menu. Only one of them is in the tab order; Left and Right Arrow move between them, Home and End jump.
- Enter, Space or Down Arrow opens a menu on its first item; Up Arrow opens it on the last.
- Inside a menu, the Dropdown Menu keys work, and Left and Right Arrow open the next menu along.
- Once a menu is open, pointing at another button in the bar opens that one instead.
- Escape closes the menu and puts focus back on its button.
Customize
Saved in this browser. Style and accent are in the header.