Menu
A list of commands that opens from a button, for the actions on an order, a row or a page that do not each need a button of their own.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';export default function MenuBasic() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Order actions </Button> )} /> <MenuContent> <MenuItem>View order</MenuItem> <MenuItem shortcut="Mod+E">Edit order</MenuItem> <MenuItem shortcut="Mod+D">Duplicate</MenuItem> <MenuItem shortcut="Mod+P">Print packing slip</MenuItem> <MenuSeparator /> <MenuItem tone="danger">Cancel order…</MenuItem> </MenuContent> </Menu> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { Menu, MenuCheckboxItem, MenuContent, MenuEmpty, MenuGroup, MenuHeader, MenuItem, MenuItemDescription, MenuItemLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger } from '@slotted/react';Triggers
The control that opens a menu is your own. In React, MenuTrigger passes the wiring to the element its render prop returns, here a Button and an IconButton; in Angular, slMenuTriggerFor goes on the button you already have. Either way the control keeps its own family’s styles and gains aria-haspopup="menu" and aria-expanded. An icon-only trigger needs an aria-label, which also names the menu. A split button pairs its primary action with a menu of alternatives. A menu opened by a secondary click or Shift+F10 on a region is the context-menu component.
import { Button, IconButton } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Menu, MenuContent, MenuItem, MenuTrigger } from '@slotted/react/menu';import { SplitButton, SplitButtonMenu, SplitButtonMenuTrigger, SplitButtonPrimary,} from '@slotted/react/split-button';export default function MenuTriggers() { return ( <Inline align="center" gap={3}> <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Export </Button> )} /> <MenuContent> <MenuItem>CSV for spreadsheets</MenuItem> <MenuItem>PDF summary</MenuItem> <MenuItem>Accounting journal</MenuItem> </MenuContent> </Menu> <Menu align="end"> <MenuTrigger render={(props) => ( <IconButton {...props} aria-label="More actions for SO-10482"> <Glyph name="ellipsis" /> </IconButton> )} /> <MenuContent> <MenuItem>Copy order number</MenuItem> <MenuItem>Add internal note</MenuItem> <MenuItem>Open customer</MenuItem> </MenuContent> </Menu> <SplitButton> <SplitButtonPrimary>Ship order</SplitButtonPrimary> <SplitButtonMenu> <SplitButtonMenuTrigger aria-label="More ways to ship" /> <MenuContent> <MenuItem>Ship and print label</MenuItem> <MenuItem>Ship part of the order…</MenuItem> <MenuItem>Schedule for tomorrow</MenuItem> </MenuContent> </SplitButtonMenu> </SplitButton> </Inline> );}Groups and separators
MenuGroup in React and sl-menu-group in Angular put a run of items under a label, and the group is named by that label, so assistive technology reads it with the first item it reaches. A separator draws a line between runs and is never focused.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuGroup, MenuItem, MenuSeparator, MenuTrigger,} from '@slotted/react/menu';export default function MenuGroups() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> SO-10482 </Button> )} /> <MenuContent> <MenuGroup label="Fulfilment"> <MenuItem>Mark as packed</MenuItem> <MenuItem>Mark as shipped</MenuItem> <MenuItem>Print packing slip</MenuItem> </MenuGroup> <MenuSeparator /> <MenuGroup label="Billing"> <MenuItem>Send invoice</MenuItem> <MenuItem>Record payment…</MenuItem> </MenuGroup> <MenuSeparator /> <MenuGroup label="Customer"> <MenuItem>Open Northwind Traders</MenuItem> <MenuItem>Email the buyer</MenuItem> </MenuGroup> </MenuContent> </Menu> );}Icons and shortcuts
icon fills the first column of an item; in Angular, put the icon in an element with slMenuItemIcon. Labels start on the same edge whether or not their item has an icon. shortcut takes a binding written as Mod+D and prints it for the reader’s platform, ⌘D on macOS and Ctrl+D elsewhere, and announces it with aria-keyshortcuts. The menu prints the shortcut only: your application binds the key.
import { Button } from '@slotted/react/button';import { Glyph, type GlyphName, Icon } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';const mark = (name: GlyphName) => ( <Icon> <Glyph name={name} /> </Icon>);export default function MenuIcons() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Invoice INV-2041 </Button> )} /> <MenuContent> <MenuItem icon={mark('copy')} shortcut="Mod+D"> Duplicate </MenuItem> <MenuItem icon={mark('external')} shortcut="Mod+Enter"> Open in new tab </MenuItem> <MenuItem icon={mark('file-text')} shortcut="Mod+P"> Print </MenuItem> <MenuItem icon={mark('pin')}>Pin to dashboard</MenuItem> <MenuItem shortcut="Shift+Mod+R">Rename…</MenuItem> <MenuSeparator /> <MenuItem icon={mark('trash')} shortcut="Mod+Backspace" tone="danger"> Delete draft </MenuItem> </MenuContent> </Menu> );}Descriptions
description writes a second line under the label, which the item references with aria-describedby; in Angular, use an element with slMenuItemDescription. A screen reader announces the label as the item’s name and the line as its description, so the line can carry the amount, the consequence or the condition of the command.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuTrigger } from '@slotted/react/menu';export default function MenuDescriptions() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Refund </Button> )} /> <MenuContent> <MenuItem description="Returns $1,240.00 to the card used at checkout."> Full refund </MenuItem> <MenuItem description="Choose the lines and the amount to return."> Partial refund… </MenuItem> <MenuItem description="Adds $1,240.00 to the customer's account balance."> Store credit </MenuItem> </MenuContent> </Menu> );}Counts and values
meta puts a count, a status or a current value at the end of the item, in a column of its own, so every value in the menu ends on one edge; in Angular, use an element with slMenuItemMeta. The value is read as part of the item’s name, and typeahead matches the label alone.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';const VIEWS = [ { label: 'Awaiting payment', count: '18' }, { label: 'Ready to ship', count: '42' }, { label: 'On hold', count: '3' }, { label: 'Returns', count: '7' },];export default function MenuMeta() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> All orders </Button> )} /> <MenuContent> <MenuItem meta="1,284">All orders</MenuItem> <MenuSeparator /> {VIEWS.map((view) => ( <MenuItem key={view.label} meta={view.count}> {view.label} </MenuItem> ))} </MenuContent> </Menu> );}Disabled items
A disabled item stays in the menu, takes focus from the arrow keys and runs nothing when pressed. It carries aria-disabled instead of the native disabled, which would take it out of the keyboard’s reach. Put the reason in its description.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';export default function MenuDisabled() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> SO-10477 · Shipped </Button> )} /> <MenuContent> <MenuItem>Track shipment</MenuItem> <MenuItem>Create return…</MenuItem> <MenuItem description="A shipped order can no longer be edited." disabled> Edit order </MenuItem> <MenuSeparator /> <MenuItem description="Create a return instead." disabled tone="danger"> Cancel order </MenuItem> </MenuContent> </Menu> );}Tones and destructive items
tone paints the label, the icon and the highlight of an item in one of the theme’s tones: accent, secondary, success, warning or danger. Give a command that deletes or cancels tone="danger", set it after a separator at the end of the menu, and end its label with an ellipsis when it asks for confirmation.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';export default function MenuDestructive() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Supplier </Button> )} /> <MenuContent> <MenuItem>Edit details</MenuItem> <MenuItem tone="success">Approve for purchasing</MenuItem> <MenuItem tone="warning">Put payments on hold</MenuItem> <MenuSeparator /> <MenuItem description="Removes Northwind Traders and its 18 open purchase orders." tone="danger" > Delete supplier… </MenuItem> </MenuContent> </Menu> );}Checkbox items
MenuCheckboxItem in React and slMenuCheckboxItem in Angular turn one option on or off and keep the menu open, so several options can be changed in one visit. Space toggles the focused item and Enter does the same. Bind checked with onCheckedChange in React, or [(checked)] in Angular.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Menu, MenuCheckboxItem, MenuContent, MenuTrigger } from '@slotted/react/menu';import { Text } from '@slotted/react/typography';export default function MenuCheckboxItems() { const [archived, setArchived] = useState(false); const [test, setTest] = useState(false); const [cancelled, setCancelled] = useState(true); const shown = [archived && 'archived', test && 'test', cancelled && 'cancelled'].filter(Boolean); return ( <Inline align="center" gap={3}> <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Show </Button> )} /> <MenuContent> <MenuCheckboxItem checked={archived} onCheckedChange={setArchived}> Archived orders </MenuCheckboxItem> <MenuCheckboxItem checked={test} onCheckedChange={setTest}> Test orders </MenuCheckboxItem> <MenuCheckboxItem checked={cancelled} onCheckedChange={setCancelled}> Cancelled orders </MenuCheckboxItem> </MenuContent> </Menu> <Text size="sm" tone="muted"> {shown.length === 0 ? 'Open orders only' : `Including ${shown.join(', ')}`} </Text> </Inline> );}Radio items
MenuRadioGroup in React and sl-menu-radio-group in Angular hold one value for the items inside them; each radio item carries the value it stands for. The menu stays open after a choice, as it does for checkbox items. Name the group with aria-label when the trigger does not say what is being chosen.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuRadioGroup, MenuRadioItem, MenuTrigger } from '@slotted/react/menu';const GROUPINGS = [ { value: 'none', label: 'No grouping' }, { value: 'status', label: 'Status' }, { value: 'customer', label: 'Customer' }, { value: 'warehouse', label: 'Warehouse' },];export default function MenuRadioItems() { const [grouping, setGrouping] = useState('status'); const current = GROUPINGS.find((option) => option.value === grouping)?.label; return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Group by: {current} </Button> )} /> <MenuContent> <MenuRadioGroup aria-label="Group orders by" onValueChange={setGrouping} value={grouping}> {GROUPINGS.map((option) => ( <MenuRadioItem key={option.value} value={option.value}> {option.label} </MenuRadioItem> ))} </MenuRadioGroup> </MenuContent> </Menu> );}Submenus
A submenu is a menu nested inside another menu’s content. In React, put a Menu with its own MenuTrigger and MenuContent among the items; in Angular, put slMenuTriggerFor on an item and the nested sl-menu after it. The item ends in a chevron, opens its submenu after the pointer rests on it for 150 milliseconds, and the pointer can cross the items between the item and the submenu without closing it. ArrowRight opens a submenu and ArrowLeft closes it, mirrored in a right-to-left document. meta on the item shows the value its submenu holds.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger,} from '@slotted/react/menu';const PEOPLE = ['Maria Chen', 'Tomás Ortega', 'Aiko Tanaka', 'Unassigned'];const WAREHOUSES = ['Rotterdam', 'Leipzig', 'Lyon', 'Gdańsk'];export default function MenuSubmenus() { const [assignee, setAssignee] = useState('Maria Chen'); return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> SO-10482 </Button> )} /> <MenuContent> <MenuItem>View order</MenuItem> <Menu> <MenuTrigger meta={assignee}>Assign to</MenuTrigger> <MenuContent> <MenuRadioGroup onValueChange={setAssignee} value={assignee}> {PEOPLE.map((person) => ( <MenuRadioItem key={person} value={person}> {person} </MenuRadioItem> ))} </MenuRadioGroup> </MenuContent> </Menu> <Menu> <MenuTrigger>Move to warehouse</MenuTrigger> <MenuContent> {WAREHOUSES.map((warehouse) => ( <MenuItem key={warehouse}>{warehouse}</MenuItem> ))} </MenuContent> </Menu> <MenuSeparator /> <MenuItem tone="danger">Cancel order…</MenuItem> </MenuContent> </Menu> );}Links
An item that navigates is an anchor with the item’s role. In React, return an a from the item’s render; in Angular, put slMenuItem on an a. The link keeps href, target and rel, and running it closes the menu.
import { Button } from '@slotted/react/button';import { Glyph, Icon } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';export default function MenuLinks() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Open </Button> )} /> <MenuContent> <MenuItem render={(props) => <a {...props} href="#order-SO-10482" />}>Order page</MenuItem> <MenuItem render={(props) => <a {...props} href="#customer-northwind" />}> Customer profile </MenuItem> <MenuSeparator /> <MenuItem icon={ <Icon> <Glyph name="external" /> </Icon> } render={(props) => ( <a {...props} href="https://example.com/carriers/track/1Z999AA10123456784" rel="noreferrer" target="_blank" /> )} > Carrier tracking </MenuItem> </MenuContent> </Menu> );}Typeahead
Typing a letter moves focus to the next item whose label starts with it, and the same letter again moves on to the following match, so D moves between DHL Express and DPD. Letters typed within 500 milliseconds of each other form one search, so typing us reaches USPS. The comparison ignores case and accents. textValue sets the text typeahead matches when the label does not start with the word a reader would type.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuTrigger } from '@slotted/react/menu';const CARRIERS = [ { name: 'DHL Express', transit: '1 day' }, { name: 'DPD', transit: '2 days' }, { name: 'FedEx', transit: '1 day' }, { name: 'GLS', transit: '3 days' }, { name: 'PostNL', transit: '2 days' }, { name: 'Royal Mail', transit: '3 days' }, { name: 'UPS', transit: '2 days' }, { name: 'USPS', transit: '5 days' },];export default function MenuTypeahead() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Ship with </Button> )} /> <MenuContent> {CARRIERS.map((carrier) => ( <MenuItem key={carrier.name} meta={carrier.transit}> {carrier.name} </MenuItem> ))} </MenuContent> </Menu> );}Long menus
The menu is never taller than the room left between its trigger and the edge of the window, and it scrolls inside that height. The arrow keys, Home, End and typeahead scroll the item they reach into view inside the menu, and the page stays where it is.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuTrigger } from '@slotted/react/menu';const LOCATIONS = [ 'Amsterdam', 'Antwerp', 'Barcelona', 'Berlin', 'Bologna', 'Bordeaux', 'Bratislava', 'Brno', 'Brussels', 'Budapest', 'Copenhagen', 'Dublin', 'Gdańsk', 'Geneva', 'Hamburg', 'Helsinki', 'Kraków', 'Leipzig', 'Lisbon', 'Ljubljana', 'Lyon', 'Madrid', 'Milan', 'Munich', 'Oslo', 'Porto', 'Prague', 'Rotterdam', 'Stockholm', 'Tallinn', 'Valencia', 'Vienna', 'Vilnius', 'Warsaw', 'Zagreb', 'Zürich',];export default function MenuLongList() { return ( <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Move to warehouse </Button> )} /> <MenuContent> {LOCATIONS.map((location) => ( <MenuItem key={location}>{location}</MenuItem> ))} </MenuContent> </Menu> );}Placement
The menu opens below its trigger, aligned to the trigger’s start edge. side sets the edge it opens from: bottom, top, left, right, or inline-start and inline-end, which follow the reading direction. align sets its position along that edge. Near the edge of the window the menu flips to the opposite side and slides along its edge to stay in view; flip and shift turn each behavior off.
import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Menu, MenuAlign, MenuContent, MenuItem, MenuSide, MenuTrigger } from '@slotted/react/menu';const PLACEMENTS: { label: string; side: MenuSide; align: MenuAlign }[] = [ { label: 'Bottom, start', side: 'bottom', align: 'start' }, { label: 'Bottom, end', side: 'bottom', align: 'end' }, { label: 'Top, start', side: 'top', align: 'start' }, { label: 'Inline end', side: 'inline-end', align: 'start' },];export default function MenuPlacement() { return ( <Inline align="center" gap={3} wrap="wrap"> {PLACEMENTS.map((placement) => ( <Menu align={placement.align} key={placement.label} side={placement.side}> <MenuTrigger render={(props) => ( <Button {...props} variant="outline"> {placement.label} </Button> )} /> <MenuContent> <MenuItem>Rename…</MenuItem> <MenuItem>Duplicate</MenuItem> <MenuItem>Archive</MenuItem> </MenuContent> </Menu> ))} </Inline> );}Sizes
size sets the width and the item height of the menu: sm for dense tables and toolbars, md for most screens, lg for sparse ones. The menu’s size is independent of the trigger’s, so set both.
import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Menu, MenuContent, MenuItem, MenuSize, MenuTrigger } from '@slotted/react/menu';const SIZES: MenuSize[] = ['sm', 'md', 'lg'];export default function MenuSizes() { return ( <Inline align="center" gap={3}> {SIZES.map((size) => ( <Menu key={size} size={size}> <MenuTrigger render={(props) => ( <Button {...props} size={size} variant="outline"> Actions, {size} </Button> )} /> <MenuContent> <MenuItem shortcut="Mod+E">Edit order</MenuItem> <MenuItem shortcut="Mod+D">Duplicate</MenuItem> <MenuItem>Print packing slip</MenuItem> </MenuContent> </Menu> ))} </Inline> );}Controlled
Pass open and update it from onOpenChange to open the menu from code or to react when it closes; in Angular, bind [(open)]. The handler receives the request, whose reason says why the menu moved: pointer, keyboard, escape, outsidePress, select, dismiss or programmatic. In Angular, openChangeRequest carries the same request.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Menu, MenuContent, MenuItem, MenuTrigger } from '@slotted/react/menu';import { Text } from '@slotted/react/typography';export default function MenuControlled() { const [open, setOpen] = useState(false); const [last, setLast] = useState('Closed'); return ( <Inline align="center" gap={3} wrap="wrap"> <Menu onOpenChange={(next, request) => { setOpen(next); setLast(`${next ? 'Opened' : 'Closed'} by ${request.reason}`); }} open={open} > <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Bulk actions </Button> )} /> <MenuContent> <MenuItem>Mark 12 orders as packed</MenuItem> <MenuItem>Print 12 packing slips</MenuItem> <MenuItem>Export selection</MenuItem> </MenuContent> </Menu> <Button onClick={() => setOpen(true)} variant="ghost"> Open from code </Button> <Text size="sm" tone="muted"> {last} </Text> </Inline> );}Keeping the menu open
An item closes the menu when it runs. closeOnSelect={false} on an item keeps the menu open for a command that is often repeated; on the menu, it applies to every command item. onSelect in React and (select) in Angular run when the item runs, and calling preventDefault() on the event keeps the menu open for that press only.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';import { Text } from '@slotted/react/typography';export default function MenuKeepOpen() { const [cartons, setCartons] = useState(24); return ( <Inline align="center" gap={3}> <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Adjust quantity </Button> )} /> <MenuContent> <MenuItem closeOnSelect={false} onSelect={() => setCartons((count) => count + 1)}> Add 1 carton </MenuItem> <MenuItem closeOnSelect={false} onSelect={() => setCartons((count) => count + 10)}> Add 10 cartons </MenuItem> <MenuItem closeOnSelect={false} onSelect={() => setCartons((count) => Math.max(0, count - 1))} > Remove 1 carton </MenuItem> <MenuSeparator /> <MenuItem onSelect={() => setCartons(24)}>Reset to ordered quantity</MenuItem> </MenuContent> </Menu> <Text size="sm" tone="muted"> {cartons} cartons </Text> </Inline> );}Loading items
Set loading on the content while the items are on their way, and put a message in MenuEmpty in React or an element with slMenuEmpty in Angular. The menu keeps its width, sets aria-busy and shows the message instead of an empty box. Here the labels are requested the first time the menu opens.
import { useRef, useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuCheckboxItem, MenuContent, MenuEmpty, MenuTrigger } from '@slotted/react/menu';const LABELS = ['Fragile', 'Gift wrap', 'Priority', 'Wholesale'];export default function MenuLoading() { const [labels, setLabels] = useState<string[] | null>(null); const requested = useRef(false); const load = (open: boolean) => { if (!open || requested.current) return; requested.current = true; setTimeout(() => setLabels(LABELS), 1200); }; return ( <Menu onOpenChange={load}> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Labels </Button> )} /> <MenuContent loading={labels === null}> {labels === null ? ( <MenuEmpty>Loading labels…</MenuEmpty> ) : ( labels.map((label) => <MenuCheckboxItem key={label}>{label}</MenuCheckboxItem>) )} </MenuContent> </Menu> );}Keyboard
Enter, Space or ArrowDown on the trigger opens the menu onto its first item, and ArrowUp opens it onto the last. ArrowDown and ArrowUp move between items and wrap at the ends, Home and End reach the first and last item, and a letter moves by typeahead. Enter runs the focused item. Escape closes the menu that holds focus and returns focus to its trigger, and Tab closes every open menu and moves focus to the next control on the page. onSelect reports whether the item ran by pointer or by keyboard.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Menu, MenuContent, MenuItem, MenuSelectEvent, MenuSeparator, MenuTrigger,} from '@slotted/react/menu';import { Text } from '@slotted/react/typography';const FORMATS = ['CSV', 'PDF', 'Excel'];export default function MenuKeyboard() { const [last, setLast] = useState('Focus Order, then press ArrowDown.'); const ran = (command: string) => (event: MenuSelectEvent) => setLast(`${command}, by ${event.reason}`); return ( <Inline align="center" gap={3} wrap="wrap"> <Menu> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} variant="outline"> Order </Button> )} /> <MenuContent> <MenuItem onSelect={ran('Edit order')} shortcut="Mod+E"> Edit order </MenuItem> <MenuItem onSelect={ran('Duplicate')} shortcut="Mod+D"> Duplicate </MenuItem> <Menu> <MenuTrigger>Export as</MenuTrigger> <MenuContent> {FORMATS.map((format) => ( <MenuItem key={format} onSelect={ran(`Export as ${format}`)}> {format} </MenuItem> ))} </MenuContent> </Menu> <MenuSeparator /> <MenuItem onSelect={ran('Archive')}>Archive</MenuItem> </MenuContent> </Menu> <Text size="sm" tone="muted"> {last} </Text> </Inline> );}Account menu
An account menu opens with who it belongs to. MenuHeader in React and an element with slMenuHeader in Angular hold an avatar, a name and an address above the commands. The header is not an item: the arrow keys never reach it, and the menu is described by it, so a screen reader announces the name once as the menu opens.
import { useState } from 'react';import { Avatar } from '@slotted/react/avatar';import { Button } from '@slotted/react/button';import { Glyph, type GlyphName, Icon } from '@slotted/react/icon';import { Menu, MenuContent, MenuHeader, MenuItem, MenuItemDescription, MenuItemLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger,} from '@slotted/react/menu';const WORKSPACES = ['Northwind Operations', 'Northwind Europe', 'Northwind Wholesale'];const mark = (name: GlyphName) => ( <Icon> <Glyph name={name} /> </Icon>);export default function MenuAccountMenu() { const [workspace, setWorkspace] = useState('Northwind Operations'); return ( <Menu align="end"> <MenuTrigger render={(props) => ( <Button {...props} start={<Avatar decorative name="Maria Chen" size="sm" />} variant="ghost" > Maria Chen </Button> )} /> <MenuContent> <MenuHeader> <Avatar decorative name="Maria Chen" size="md" /> <MenuItemLabel>Maria Chen</MenuItemLabel> <MenuItemDescription>maria.chen@northwind.example</MenuItemDescription> </MenuHeader> <MenuSeparator /> <MenuItem icon={mark('person')}>Profile</MenuItem> <MenuItem icon={mark('bell')}>Notifications</MenuItem> <Menu> <MenuTrigger meta={workspace.replace('Northwind ', '')}>Workspace</MenuTrigger> <MenuContent> <MenuRadioGroup onValueChange={setWorkspace} value={workspace}> {WORKSPACES.map((name) => ( <MenuRadioItem key={name} value={name}> {name} </MenuRadioItem> ))} </MenuRadioGroup> </MenuContent> </Menu> <MenuSeparator /> <MenuItem icon={mark('arrow-left')} tone="danger"> Sign out </MenuItem> </MenuContent> </Menu> );}Row actions with confirmation
Each row of a table ends in an icon button that opens the row’s commands, labelled with the row it acts on. Delete opens an alert dialog instead of deleting at once, and the row is removed only when the deletion is confirmed. The menu closes before the dialog opens, and Keep order returns focus to the row’s button.
import { useState } from 'react';import { Button, IconButton } from '@slotted/react/button';import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogIcon, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle,} from '@slotted/react/dialog';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@slotted/react/menu';import { Table, TableBody, TableCell, TableColumnHeader, TableContent, TableHead, TableRow, TableRowHeader,} from '@slotted/react/table';interface Order { id: string; customer: string; total: string;}const ORDERS: Order[] = [ { id: 'SO-10482', customer: 'Northwind Traders', total: '$1,240.00' }, { id: 'SO-10483', customer: 'Contoso Foods', total: '$860.50' }, { id: 'SO-10484', customer: 'Fabrikam Supply', total: '$2,315.75' },];export default function MenuRowActions() { const [orders, setOrders] = useState(ORDERS); const [pending, setPending] = useState<Order | null>(null); const [confirming, setConfirming] = useState(false); return ( <> <Table columns={4}> <TableContent> <TableHead> <TableRow> <TableColumnHeader>Order</TableColumnHeader> <TableColumnHeader>Customer</TableColumnHeader> <TableColumnHeader numeric>Total</TableColumnHeader> <TableColumnHeader align="end">Actions</TableColumnHeader> </TableRow> </TableHead> <TableBody> {orders.map((order) => ( <TableRow key={order.id} value={order.id}> <TableRowHeader>{order.id}</TableRowHeader> <TableCell>{order.customer}</TableCell> <TableCell numeric>{order.total}</TableCell> <TableCell align="end"> <Menu align="end"> <MenuTrigger render={(props) => ( <IconButton {...props} aria-label={`Actions for ${order.id}`} size="sm"> <Glyph name="ellipsis" /> </IconButton> )} /> <MenuContent> <MenuItem>View order</MenuItem> <MenuItem shortcut="Mod+D">Duplicate</MenuItem> <MenuSeparator /> <MenuItem onSelect={() => { setPending(order); setConfirming(true); }} tone="danger" > Delete order… </MenuItem> </MenuContent> </Menu> </TableCell> </TableRow> ))} </TableBody> </TableContent> </Table> <AlertDialog onOpenChange={setConfirming} open={confirming}> <DialogContent> <DialogHeader> <AlertDialogIcon /> <DialogTitle>Delete {pending?.id}?</DialogTitle> <DialogDescription> The order for {pending?.customer} and its invoice are removed. This cannot be undone. </DialogDescription> </DialogHeader> <DialogFooter> <AlertDialogCancel render={(props) => ( <Button {...props} tone="secondary" variant="outline"> Keep order </Button> )} /> <AlertDialogAction onClick={() => setOrders((rows) => rows.filter((row) => row.id !== pending?.id))} render={(props) => ( <Button {...props} tone="danger"> Delete order </Button> )} /> </DialogFooter> </DialogContent> </AlertDialog> </> );}Column visibility
A menu of checkbox items above a table shows and hides its columns. The menu stays open while columns are switched, and the table follows each change.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuTrigger } from '@slotted/react/menu';import { Stack } from '@slotted/react/stack';import { Table, TableBody, TableCell, TableColumnHeader, TableContent, TableHead, TableRow, TableRowHeader,} from '@slotted/react/table';type Column = 'customer' | 'status' | 'warehouse' | 'total';const COLUMNS: { key: Column; label: string; numeric?: boolean }[] = [ { key: 'customer', label: 'Customer' }, { key: 'status', label: 'Status' }, { key: 'warehouse', label: 'Warehouse' }, { key: 'total', label: 'Total', numeric: true },];const ORDERS: (Record<Column, string> & { id: string })[] = [ { id: 'SO-10482', customer: 'Northwind Traders', status: 'Packed', warehouse: 'Rotterdam', total: '$1,240.00', }, { id: 'SO-10483', customer: 'Contoso Foods', status: 'Awaiting payment', warehouse: 'Leipzig', total: '$860.50', }, { id: 'SO-10484', customer: 'Fabrikam Supply', status: 'Shipped', warehouse: 'Lyon', total: '$2,315.75', },];export default function MenuColumnVisibility() { const [visible, setVisible] = useState<Record<Column, boolean>>({ customer: true, status: true, warehouse: false, total: true, }); const shown = COLUMNS.filter((column) => visible[column.key]); return ( <Stack align="end" gap={3}> <Menu align="end"> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} size="sm" variant="outline"> Columns </Button> )} /> <MenuContent> <MenuGroup label="Show columns"> {COLUMNS.map((column) => ( <MenuCheckboxItem checked={visible[column.key]} key={column.key} onCheckedChange={(checked) => setVisible((current) => ({ ...current, [column.key]: checked })) } > {column.label} </MenuCheckboxItem> ))} </MenuGroup> </MenuContent> </Menu> <Table columns={shown.length + 1}> <TableContent> <TableHead> <TableRow> <TableColumnHeader>Order</TableColumnHeader> {shown.map((column) => ( <TableColumnHeader key={column.key} numeric={column.numeric}> {column.label} </TableColumnHeader> ))} </TableRow> </TableHead> <TableBody> {ORDERS.map((order) => ( <TableRow key={order.id} value={order.id}> <TableRowHeader>{order.id}</TableRowHeader> {shown.map((column) => ( <TableCell key={column.key} numeric={column.numeric}> {order[column.key]} </TableCell> ))} </TableRow> ))} </TableBody> </TableContent> </Table> </Stack> );}Sort menu
A radio group holds the table’s sort order, and the trigger names the order in force. Choosing an option reorders the rows and leaves the menu open; Escape or a press outside closes it.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Menu, MenuContent, MenuRadioGroup, MenuRadioItem, MenuTrigger } from '@slotted/react/menu';import { Stack } from '@slotted/react/stack';import { Table, TableBody, TableCell, TableColumnHeader, TableContent, TableHead, TableRow, TableRowHeader,} from '@slotted/react/table';interface Order { id: string; customer: string; placed: string; total: number;}const ORDERS: Order[] = [ { id: 'SO-10482', customer: 'Northwind Traders', placed: '2026-10-02', total: 1240 }, { id: 'SO-10483', customer: 'Contoso Foods', placed: '2026-10-03', total: 860.5 }, { id: 'SO-10484', customer: 'Fabrikam Supply', placed: '2026-10-01', total: 2315.75 }, { id: 'SO-10485', customer: 'Adventure Works', placed: '2026-10-04', total: 412 },];const SORTS: { value: string; label: string; compare: (a: Order, b: Order) => number }[] = [ { value: 'newest', label: 'Newest first', compare: (a, b) => b.placed.localeCompare(a.placed) }, { value: 'oldest', label: 'Oldest first', compare: (a, b) => a.placed.localeCompare(b.placed) }, { value: 'total-desc', label: 'Highest total', compare: (a, b) => b.total - a.total }, { value: 'total-asc', label: 'Lowest total', compare: (a, b) => a.total - b.total }, { value: 'customer', label: 'Customer, A to Z', compare: (a, b) => a.customer.localeCompare(b.customer), },];const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });export default function MenuSortMenu() { const [sort, setSort] = useState('newest'); const current = SORTS.find((option) => option.value === sort) ?? SORTS[0]!; const rows = [...ORDERS].sort(current.compare); return ( <Stack align="end" gap={3}> <Menu align="end"> <MenuTrigger render={(props) => ( <Button {...props} end={<Glyph name="chevron-down" />} size="sm" variant="outline"> Sort: {current.label} </Button> )} /> <MenuContent> <MenuRadioGroup aria-label="Sort orders" onValueChange={setSort} value={sort}> {SORTS.map((option) => ( <MenuRadioItem key={option.value} value={option.value}> {option.label} </MenuRadioItem> ))} </MenuRadioGroup> </MenuContent> </Menu> <Table columns={4}> <TableContent> <TableHead> <TableRow> <TableColumnHeader>Order</TableColumnHeader> <TableColumnHeader>Customer</TableColumnHeader> <TableColumnHeader>Placed</TableColumnHeader> <TableColumnHeader numeric>Total</TableColumnHeader> </TableRow> </TableHead> <TableBody> {rows.map((order) => ( <TableRow key={order.id} value={order.id}> <TableRowHeader>{order.id}</TableRowHeader> <TableCell>{order.customer}</TableCell> <TableCell>{order.placed}</TableCell> <TableCell numeric>{money.format(order.total)}</TableCell> </TableRow> ))} </TableBody> </TableContent> </Table> </Stack> );}Accessibility
| Key | Effect | Focus |
|---|---|---|
| Enter | on an item with a submenu, opens it; on any other item, runs it and closes the menu unless closeOnSelect is false; on the trigger, opens the menu | the submenu's first item, or the trigger the menu returns to |
| Space | as Enter, and on a checkbox or radio item changes the state without closing the menu | unchanged on a checkbox or radio item, otherwise as Enter |
| ArrowDown | moves to the next item, wrapping when loop is true; on a menubar trigger or a closed menu's trigger, opens the surface | the next item, or the surface's first item |
| ArrowUp | moves to the previous item, wrapping when loop is true; on a trigger, opens the surface onto its last item, which is the pattern's optional behavior | the previous item, or the surface's last item |
| ArrowRight | the inline-end direction in a left-to-right document and the inline-start one in a right-to-left document: opens a submenu from an item that has one, moves to the next menubar trigger from an item that does not, and moves between triggers on a horizontal menubar | the submenu's first item, or the next menubar trigger, whose menu opens without focus entering it |
| ArrowLeft | the inline-start direction, and the mirror of ArrowRight in a right-to-left document: closes a submenu back to its parent item, or closes it and moves to the previous menubar trigger, and moves between triggers on a horizontal menubar | the parent item, or the previous menubar trigger |
| Home | moves to the first item of the surface holding focus | the first item |
| End | moves to the last item of the surface holding focus | the last item |
| Printable character | moves to the next item whose label begins with the sequence typed; the same character pressed again cycles through the items beginning with it | the matched item |
| Escape | closes the surface holding focus, and only that one | the trigger, or the parent item when the surface is a submenu |
| Tab | closes every open menu and moves focus out, which is the pattern's rule for a composite widget | the next element in the page after the trigger |
| Shift+Tab | the same, backwards | the element before the trigger |
- An item is a native button, so Enter and Space run it and the pointer behaves as the browser's own. role="menuitem" replaces role="button", so a screen reader announces a menu item. A link item is an a that keeps its href and takes the same role.
- Menu supplies the keyboard of the WAI-ARIA menu pattern: the arrow keys move and wrap, Home and End reach the ends, letters move by typeahead, the inline-end arrow opens a submenu and the inline-start arrow closes it, Escape closes the menu that holds focus, and Tab closes every menu and moves focus past the trigger.
- A disabled item stays focusable and carries aria-disabled instead of the native disabled attribute, so a keyboard user can still find a command that is unavailable. A natively disabled button cannot take focus.
- A header is not an item and never takes focus, because role="menu" owns only items, groups and separators. The surface references it with aria-describedby, joined to any description you give, so a screen reader announces who the menu belongs to once, as it opens.
- The surface is named by its trigger, or by its own aria-label. A checkbox or radio item announces its state through aria-checked, a group is named by its label, and a shortcut is announced through aria-keyshortcuts while the printed keys are hidden, so the item's name stays the command.
API
Menu
Props
openboolean | undefined- Whether the menu is open. Passing it makes the menu controlled for its lifetime; update it from onOpenChange.
defaultOpenbooleanDefaultfalse- Whether an uncontrolled menu starts open. Read once.
onOpenChange(open, request) => void- Called before the menu opens or closes, with the reason and the event. The request can be cancelled.
valuestring- On Menu, MenuRadioGroup, MenuRadioItemOn a Menu inside a Menubar, the name the bar knows it by; a menu on its own needs none. On a MenuRadioGroup, the chosen value, which makes the group controlled. On a MenuRadioItem, the value the item stands for.
checkedboolean | undefined- On MenuCheckboxItemWhether the option is on. Passing it makes the item controlled.
defaultCheckedbooleanDefaultfalse- On MenuCheckboxItemWhether an uncontrolled option starts on.
onCheckedChange(checked, request) => void- On MenuCheckboxItemCalled before the option changes, with pointer or keyboard as the reason.
defaultValuestring- On MenuRadioGroupThe value an uncontrolled group starts with.
onValueChange(value, request) => void- On MenuRadioGroupCalled before the chosen value changes, with pointer or keyboard as the reason.
size'sm' | 'md' | 'lg'Defaultmd- The width of the surface and the height of its items.
width'content' | 'anchor'Defaultcontent- content: the surface takes its own measure; anchor: it is exactly as wide as its trigger, capped by the available width. A submenu is always content.
side'top' | 'bottom' | 'inline-start' | 'inline-end' | 'left' | 'right'Defaultbottom- The edge of the trigger the surface opens from. inline-start and inline-end follow the reading direction.
align'start' | 'center' | 'end'Defaultstart- Where the surface sits along that edge.
anchorPositionerAnchor | null- What the surface is positioned against instead of the trigger, such as a table row or a point. Focus still returns to the trigger.
finalFocusElement | RefObject | stringDefault the trigger- Where focus goes when the menu closes, for a trigger that is gone by then, such as the actions button of a deleted row.
mount'active' | 'lazy' | 'eager'Defaultactive- When the surface is in the document: only while open, from the first open on, or from the start.
strategy'absolute' | 'fixed'Defaultabsolute- The CSS position the layer is placed with.
closeOnSelectbooleanDefaulttrue- On Menu, MenuItemWhether running an item closes the menu. Checkbox and radio items keep it open unless they set it themselves.
loopbooleanDefaulttrue- Whether the arrow keys wrap from the last item to the first.
typeaheadbooleanDefaulttrue- Whether typing moves focus to the item whose label starts with the typed text.
openOnHoverbooleanDefaulttrue- Whether a submenu opens when the pointer rests on its item.
closeOnEscapebooleanDefaulttrue- Whether Escape closes the menu that holds focus.
closeOnOutsidePressbooleanDefaulttrue- Whether a press outside the menu closes every open menu.
flipbooleanDefaulttrue- Whether the surface moves to the opposite side when it would leave the window.
shiftbooleanDefaulttrue- Whether the surface slides along its edge to stay in the window.
hideWhenDetachedbooleanDefaulttrue- Whether the surface hides once its trigger has scrolled out of view.
portalbooleanDefaulttrue- Whether the layer is rendered at the end of the document.
presentation'popover' | 'auto'Defaultpopover- On Menu, MenuDefaultsProviderauto draws the menu as a bottom sheet under (max-width: 480px) and (pointer: coarse): modal, as ActionSheet draws its actions, every item at least --slotted-target-min tall, dismissed by its grip, its scrim, Escape and the platform’s way back, with focus given back to the trigger. A submenu opens as a second step of the same sheet. A menu on a bar stays anchored.
messagesPartial<MenuMessages>- Words laid over the catalog of the language in force: back, the name of the control that returns from a submenu step to the first step of a sheet.
disabledbooleanDefaultfalse- On Menu, MenuItemA disabled menu never opens, and its trigger keeps aria-expanded="false". A disabled item stays focusable and runs nothing.
loadingbooleanDefaultfalse- On MenuContentWhether the items are on their way. The surface keeps its width, sets aria-busy and shows the MenuEmpty message.
sideOffsetnumberDefault0- Extra distance from the trigger, in pixels, beyond the layer's own gap.
alignOffsetnumberDefault0- Distance along the alignment edge, in pixels.
collisionPaddingnumberDefault8- The distance, in pixels, the surface keeps from the edge of the window.
submenuOpenDelaynumberDefault150- How long, in milliseconds, the pointer rests on an item before its submenu opens.
submenuCloseDelaynumberDefault300- How long, in milliseconds, a submenu stays open while the pointer travels toward it without reaching it.
typeaheadTimeoutnumberDefault500- How long, in milliseconds, typed letters keep adding to one search.
iconReactNode- On MenuItem, MenuTriggerThe icon in the first column of the item.
descriptionReactNode- On MenuItem, MenuCheckboxItem, MenuRadioItemThe line under the label, referenced with aria-describedby; the label alone names the item.
metaReactNode- On MenuItem, MenuTriggerA count, a status or the value a submenu holds, in its own column before the shortcut or the chevron.
shortcutstring- On MenuItemA shortcut written as Mod+K, printed for the platform and announced with aria-keyshortcuts. The menu does not bind the key.
textValuestring- On MenuItemThe text typeahead matches, when the label does not start with the word a reader would type.
tone'accent' | 'secondary' | 'success' | 'warning' | 'danger'- On MenuItemThe theme tone of the label, the icon and the highlight. A destructive command takes danger.
labelReactNode- On MenuGroupThe name of the group, rendered as its group-label part.
render(props) => ReactNode- On MenuTrigger, MenuContent, MenuItemRenders your own element with the wiring, the state attributes and the handlers spread on it. On MenuItem, return an a for a link item.
Events
| Name | Payload | When |
|---|---|---|
onOpenChange | (open: boolean, request: MenuChangeRequest) | Before the menu opens or closes. request.reason is pointer, keyboard, escape, outsidePress, select, dismiss or programmatic, request.source is the event, and request.cancel() refuses the change. |
onCheckedChange | (checked: boolean, request: MenuCheckedChangeRequest) | Before a checkbox item changes. request.reason is pointer or keyboard. |
onValueChange | (value: string, request: MenuValueChangeRequest) | Before a radio group changes its value. request.reason is pointer or keyboard. |
onSelect | (event: MenuSelectEvent) | When an item runs. event.reason is pointer or keyboard, and event.preventDefault() keeps the menu open for this press only. |
Composition
MenuDefaultsProvidercomponent- On ApplicationSets any axis once for every menu under it, and container sets where the layers are rendered. A value set on one menu still wins.
renderprop- On MenuTrigger, MenuContent, MenuItemReplaces the rendered element with your own, keeping the wiring, the state attributes and the handlers.
MenuHeadercomponent- On MenuContentThe block above the commands. Its children are the media, a MenuItemLabel and a MenuItemDescription, and the surface is described by it.
MenuItemMeta, MenuItemIcon, MenuItemLabel, MenuItemDescription, MenuItemShortcutcomponent- On MenuItem childrenThe parts of an item, for an item written from its parts instead of from props.
MenuGroupLabelcomponent- On MenuGroupThe group-label part, for a label written as a child instead of with label.
MenuEmptycomponent- On MenuContentThe message shown while loading is set or when the menu holds no items.
useMenuhook- On Inside a MenuReads the menu around a part: whether it is open, its resolved axes and toggle().
refprop- A handle with open(), close() and focus(), for a shortcut your application binds outside the menu.
native propsattributes- On Every partAny attribute the underlying element takes reaches it. Your own onClick, onKeyDown or onPointerEnter runs before the menu's handler, and preventDefault() in it skips the menu's.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | div, or the element render returns | Yes | The layer the menu is positioned on. It carries data-ui="menu", the resolved size, side and align, and data-open while the menu is open. The gap between the trigger and the surface is the layer's own padding, so the pointer never crosses the page on its way into a submenu. |
backdrop | div | No | The scrim over the page while the menu is a sheet (presentation="auto" on a phone), aria-hidden. A press on it dismisses every step; on a second step it is clear, since the first already dims the page. |
content | div | Yes | The painted surface, carrying role="menu". It lays out the columns every item uses, is never taller than the room left in the window, and scrolls inside that height. |
grip | span | No | The bar at the top of the sheet, aria-hidden. A pull down on it dismisses the step it belongs to. |
step | div | No | The head of a submenu drawn as the second step of a sheet: the back control, then the name of the item that opened it. |
back | button | No | Returns to the first step of the sheet, named by messages.back, with focus on the item that opened the step. |
title | div | No | The name of the item that opened the step, as a reader hears it. |
header | div | No | Who the menu belongs to: an avatar or a mark, a name in MenuItemLabel and a line under it in MenuItemDescription. It is not an item and never takes focus; the surface references it with aria-describedby, so a screen reader announces it once as the menu opens. |
group | div | No | A run of items with role="group", named by its label. Its items keep the menu's columns, so their labels line up with the items outside the group. |
group-label | div | No | The name of a group, which the group references with aria-labelledby. |
item | button, or a when the item is a link | Yes | One command, option or choice, with role menuitem, menuitemcheckbox or menuitemradio. A disabled item keeps its place among the items the arrow keys reach and carries aria-disabled, because the WAI-ARIA pattern keeps disabled items focusable. |
indicator | span | No | The check of a checkbox item or the dot of a radio item. Its box is present whether or not the item is checked, so the labels do not move when an option changes. |
icon | span | No | The icon in the first column: a Glyph inside an Icon, or any element you pass. The column sizes it and does not paint it. It shares the column with the indicator. |
label | span | Yes | The item's text, and the only column that wraps when the surface is narrow. |
description | span | No | The line under the label, which the item references with aria-describedby, so a screen reader announces the command as the name and this line as its description. |
meta | span | No | A count, a status or the value a submenu holds, end-aligned in its own column before the shortcut, so the values of every item line up. It is part of the accessible name; typeahead matches the label alone. |
shortcut | span | No | The shortcut printed for the platform: ⌘K on macOS, Ctrl+K elsewhere. It is aria-hidden, because the item announces the shortcut with aria-keyshortcuts. |
separator | hr | No | A line between two runs of items. It is never focused and does nothing when pressed. |
empty | div | No | The message the surface shows while it is loading or when it holds no items. The surface keeps its width instead of collapsing around it. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every menu inside it.
Menu tokens
| Token | Default |
|---|---|
--slotted-menu-backdrop-filter | none |
--slotted-menu-border-color | var(--slotted-border-subtle, #e2e8f0) |
--slotted-menu-gap | var(--slotted-space-2, 0.25rem) |
--slotted-menu-group-label-height | calc(var(--_secondary-leading) + 2 * var(--slotted-space-2, 0.25rem)) |
--slotted-menu-highlight | var(--slotted-tone-secondary-subtle-hover) |
--slotted-menu-highlight-active | var(--slotted-tone-secondary-subtle-active) |
--slotted-menu-item-radius | max(0px, calc(var(--_radius) - var(--_inset-inline))) |
--slotted-menu-measure | 16rem |
--slotted-menu-measure-lg | 20rem |
--slotted-menu-measure-sm | 14rem |
--slotted-menu-min-measure | 12rem |
--slotted-menu-padding-block | var(--slotted-space-2, 0.25rem) |
--slotted-menu-padding-inline | var(--slotted-space-2, 0.25rem) |
--slotted-menu-radius | var(--slotted-radius-lg, 8px) |
--slotted-menu-separator-color | var(--_border-color) |
--slotted-menu-shadow | var(--slotted-shadow-md) |
--slotted-menu-surface | var(--slotted-surface-raised, #ffffff) |
--slotted-menu-text | var(--slotted-text, #0f172a) |
--slotted-menu-text-muted | var(--slotted-text-muted, #5b6b7f) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-border-strong | Set per scheme by the theme |
--slotted-border-subtle | Set per scheme by the theme |
--slotted-border-width-thin | 1px |
--slotted-control-font-size-lg | comfortable 14px · compact 13px · dense 12px |
--slotted-control-font-size-md | comfortable 13px · compact 12px · dense 12px |
--slotted-control-font-size-sm | comfortable 12px · compact 12px · dense 12px |
--slotted-control-gap-lg | comfortable 8px · compact 6px · dense 6px |
--slotted-control-gap-md | comfortable 8px · compact 6px · dense 4px |
--slotted-control-gap-sm | comfortable 6px · compact 4px · dense 4px |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-control-icon-size-lg | comfortable 18px · compact 16px · dense 14px |
--slotted-control-icon-size-md | comfortable 16px · compact 14px · dense 13px |
--slotted-control-icon-size-sm | comfortable 14px · compact 13px · dense 12px |
--slotted-control-padding-inline-lg | comfortable 16px · compact 12px · dense 10px |
--slotted-control-padding-inline-md | comfortable 13px · compact 10px · dense 8px |
--slotted-control-padding-inline-sm | comfortable 10px · compact 8px · dense 6px |
--slotted-control-transition-duration | var(--slotted-duration-short) |
--slotted-control-transition-easing | var(--slotted-easing-standard) |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-drawer-border-color | var(--_border-color) |
--slotted-drawer-radius | var(--_radius) |
--slotted-drawer-resizer-line-color | var(--slotted-border-strong, ButtonBorder) |
--slotted-drawer-scrim | var(--slotted-scrim, Canvas) |
--slotted-drawer-scrim-backdrop-filter | none |
--slotted-drawer-slide-duration | var(--slotted-duration-short) |
--slotted-drawer-slide-easing | var(--slotted-easing-standard) |
--slotted-drawer-slide-exit-duration | var(--slotted-drawer-slide-duration, var(--slotted-duration-short)) |
--slotted-drawer-slide-exit-easing | var(--slotted-easing-exit) |
--slotted-drawer-surface | var(--_surface) |
--slotted-duration-long | 320ms |
--slotted-duration-medium | 200ms |
--slotted-duration-short | 120ms |
--slotted-easing-enter | cubic-bezier(0.05, 0.7, 0.1, 1) |
--slotted-easing-exit | cubic-bezier(0.3, 0, 0.8, 0.15) |
--slotted-easing-standard | cubic-bezier(0.2, 0, 0, 1) |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-font-family-heading | var(--slotted-font-family-sans) |
--slotted-font-family-sans | 'Geist Variable', ui-sans-serif, system-ui, sans-serif |
--slotted-font-size-xs | 0.75rem |
--slotted-font-weight-semibold | 600 |
--slotted-line-height-md | 1.5 |
--slotted-line-height-sm | 1.45 |
--slotted-overlay-max-block-size | 100vh |
--slotted-radius-lg | 8px |
--slotted-scrim | Set per scheme by the theme |
--slotted-shadow-lg | Set per scheme by the theme |
--slotted-shadow-md | Set per scheme by the theme |
--slotted-space-1 | 0.125rem |
--slotted-space-11 | 3rem |
--slotted-space-2 | 0.25rem |
--slotted-space-5 | 0.75rem |
--slotted-space-6 | 1rem |
--slotted-surface-raised | Set per scheme by the theme |
--slotted-target-min | 24px |
--slotted-text | Set per scheme by the theme |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-accent-subtle-active | Set per scheme by the theme |
--slotted-tone-accent-surface | Set per scheme by the theme |
--slotted-tone-accent-text | Set per scheme by the theme |
--slotted-tone-danger-subtle-active | Set per scheme by the theme |
--slotted-tone-danger-surface | Set per scheme by the theme |
--slotted-tone-danger-text | Set per scheme by the theme |
--slotted-tone-secondary-subtle-active | Set per scheme by the theme |
--slotted-tone-secondary-subtle-hover | Set per scheme by the theme |
--slotted-tone-secondary-surface | Set per scheme by the theme |
--slotted-tone-secondary-text | Set per scheme by the theme |
--slotted-tone-success-subtle-active | Set per scheme by the theme |
--slotted-tone-success-surface | Set per scheme by the theme |
--slotted-tone-success-text | Set per scheme by the theme |
--slotted-tone-warning-subtle-active | Set per scheme by the theme |
--slotted-tone-warning-surface | Set per scheme by the theme |
--slotted-tone-warning-text | Set per scheme by the theme |
--slotted-z-index-popover | 1100 |