Toolbars
A row of commands that fits the width it is given: what does not fit goes into a ⋯ menu, in an order the caller sets, and comes back as the room does.
A row of commands is a Toolbar. It decides what fits; you decide the order, what stays
together and what goes first. Never hide a command at a breakpoint by hand.
Drag the frame's corner. As the bar narrows, the search narrows, the filters drop their names,
the empty search gives way to its icon, and then the filters go into the ⋯ menu, the one at the
end first. New issue stays to the last. Set a filter away from its default and it leaves the
bar last; once it is in the ⋯, the ⋯ counts it.
What gives way, in order#
Each step is taken only when the one before has not made enough room, and a wider bar takes them back in reverse, so a width always gets the same layout however it was reached.
- A
ToolbarSpacergives up its room, and aToolbarSearchor aflexToolbarItemnarrows. - On a fine pointer, or any under
labelCollapse="always", the words of commands with an icon hide, the lowestpriorityfirst, every command of a priority at once. The icon stays, and the tooltip says the words; a count stays beside the icon, and the tooltip says it after them. A primary or destructive command keeps its words: what it does is said before it is done. - A
SegmentedControlbecomes a dropdown of its value, and an empty search becomes its icon. - Commands go into the
⋯menu: the lowestpriorityfirst; within a priority, those at their defaults before those set away from them (a filter in use, a toggle that is on); with aToolbarSpacer, the cluster before it before the one after it; each from the end of its cluster. - Commands with
priority="pin"go last of all, and only those with a form in the menu. Then a title withkeepCharsgives up the characters it kept. What is still too wide scrolls rather than being cut off.
The ⋯ stands at the end of the first cluster that overflowed, so a command at the far end, the
one a reader looks for there, keeps its place. Put it somewhere else with ToolbarOverflow.
None of this changes the bar's height. It is as tall as its tallest part in any of its forms, so
what lies below it stays put as a search gives way to its icon, a segmented control to its
dropdown, or a part to the ⋯.
What fits follows the style and the pointer#
How many commands fit at a width is whatever their sizes in the style and on the pointer in use allow: a style with smaller controls holds more, and a coarse pointer, whose commands keep room beside them for a finger, holds fewer. So a toolbar states an order, groups and priorities, never a breakpoint: a command hidden at a breakpoint follows the window rather than the bar, and stays hidden when a denser style would have made room for it.
On a coarse pointer no words hide: a tooltip never shows under a finger, so an icon alone would
lose its name. The exception is a bar whose commands their icons name well enough, beside words
of its own that need the room more: a closed AttachmentList card's header, whose Download
all gives up its words before the files' names give up theirs. Such a bar sets
labelCollapse="always", and its words hide under any pointer before a command moves. Otherwise
a command that does not fit moves into the menu whole, words and all, and as it stands: a disabled command is a disabled item, one that stays on a check item, and a command or a
segment with an intent an item in that colour
(Actions & buttons). A
SegmentedControl disabled whole offers its choices there disabled too.
Clusters and the ⋯#
A ToolbarSpacer splits the bar into the commands at its start and those at its end, as Mail's
thread toolbar keeps Star at the far end. Commands that belong together go in a
ToolbarGroup, which moves into the menu whole and is parted from its neighbours there; a
ToolbarSeparator between commands parts them in the menu too. A separator left with nothing to
part, at an end or beside the ⋯, is not drawn.
Commands that are always in the ⋯, Mail's Forward and Copy link, are the children of a
ToolbarOverflow. Its ⋯ is always shown, and what the bar moves into it goes above them.
A SelectionBar is a toolbar
too: its select-all checkbox, the count and Clear selection never go into the ⋯, and what
it holds between them gives way as here. Give it the parts themselves, never a Toolbar of their
own: a toolbar in another's row draws a second bar, a second Tab stop and a second ⋯, and warns
in development.
One of a few#
Both pick one of a few, and they give way differently.
- A
SegmentedControlis a mode of the tool with words: a view, a typing mode. Short of room it first becomes a dropdown of its current value, then radio items in the⋯menu. - A
ToolbarGroupwithselection="single"is a row of icon toggles: an alignment. It stays a row until it moves into the menu whole, as radio items under itslabel. Withselection="multiple"each toggle is on or off on its own, bold and italic, and they move as check items.
Counts#
A segment or a command that leads to a number of things, Open and Closed over a list of
issues or Muted in an inbox, says how many with a SegmentedControlCount or a ToolbarCount
after its words, never with the number typed into them. The count is drawn as a row's count is,
smaller and muted, and in the words' own colour on the segment or the command that is pressed,
where a muted number would fall below the contrast the words keep. It goes where its segment goes,
onto the button of the dropdown the run becomes and to the end of its row in that dropdown and in
the ⋯, and is read with the words: Open 12.
Menus, filters and other parts#
A command whose menu should follow it into the ⋯ is a ToolbarMenu, which becomes a submenu
there, its value beside its name. A FilterMenu in a toolbar opens from a ToolbarMenuButton,
the button a ToolbarMenu draws, so a filter and a menu beside it read as one kind of control: its
icon, its words, its value and a ▾, the words hiding to fit while the button keeps its size, its
value and its ▾. In the ⋯ it becomes a row naming its toolbarLabel and toolbarValue;
choosing the row opens the filter against the ⋯ and gives the focus back to the ⋯ when it
closes. Opening it moves nothing, and while it is open it stays where
it stood, on the bar or in the ⋯, however its picks change its width, so a selection="multiple"
one opened from the ⋯ takes several picks in a row and still closes back to the ⋯. Should a
pick widen it past the room left, or the bar narrow, the others give way around it, and those
before it move its trigger; its menu stays put while the pointer is on it or near it, and slides
over once the pointer has gone. A SplitButton becomes its command and a submenu of the
others, or the others after it with overflow="group".
On a phone the ⋯ menu is a sheet from the bottom edge, as every menu is there
(Overlays), and a submenu in it takes its place. A
FilterMenu's row hands the sheet over to the filter's own, with a ‹ in its title bar that hands
it back to the ⋯ menu; its close button closes it, the focus back on the ⋯.
A ToolbarButton wrapped in a menu or popover trigger of your own cannot be followed into the
menu, since its surface would have nothing on the bar to open from: it stays on the bar, and warns
in development. Make it a ToolbarMenu, or a ToolbarItem with an overflow form.
Anything else is a ToolbarItem. Give it overflow, what it is in the ⋯ menu, or it stays on
the bar. That form is drawn in the menu, outside the item: it reads nothing from the providers
inside the item, so take what it needs from the code it is written in. A command moved into the
menu is called with the menu item's event, not its button's.
A title that takes the room the commands leave is a ToolbarItem with flex and a minWidth,
never text that grows or shrinks by itself: the bar cannot know how wide such text wants to be,
so it moves the wrong parts, and warns in development. A title the reader names the thing by, a
file's name, takes keepChars instead, its text in a ToolbarItemText: the item keeps that many
of its first characters, all of a shorter title, while a search beside it narrows to its
minWidth and the commands go into the ⋯.
A button or a link an item draws itself (a name that opens a file, a trigger of the item's own
menu) is wrapped in ToolbarFocusable, so it shares the bar's one Tab stop and the arrow keys
reach it; left bare, it is a Tab stop of its own beside the bar's.
A strip that draws itself, such as a block's header or a dialog's title bar, is a Toolbar with
pane={false}, which leaves its look to the strip's own classes; size="xs" gives its commands
the smallest size.
A block's header keeps one order, out from its name: the view's own commands, Source, the
app's own, Download, Open in the viewer and Copy, then the ⋯. The parts it shares
with every block carry their own priorities, so they give way in the same order on every block:
Download first, its priority the lowest; then the rest from the end, ⤢ before the view's
commands; and Copy, whose priority is the highest, last of all. A toggle that is on, Source with
the text showing, leaves after the other parts of its priority. See
Long content for what each part is.
Set away from its default#
A filter in use changes what the rest of the page shows, so it is the part a reader most needs to
find again. A part set away from its default leaves the bar last within its priority. Once it is in
the ⋯, the ⋯ counts it, and its row in the menu is marked: a dot before its value, or after its
name when it shows none, and the value in the row's own colour rather than the quiet one of the
rows at their defaults. A list that has been narrowed keeps the reason in sight.
Two kinds of part know it by themselves: a ToolbarButton whose aria-pressed is on, such as
Mail's Star, and a ToolbarGroup with selection="multiple" that has something chosen. Tell
the rest: active on a ToolbarMenu, a ToolbarItem, a ToolbarButton or a ToolbarGroup, and
toolbarActive on a FilterMenu or a SegmentedControl, which also stand outside toolbars, where
active would read as their chosen value. Pass it while the value differs from the one the page
starts with, as the example's filters do with active={status !== "open"}.
When given, active overrides what a part knows by itself: active={false} leaves a pressed
toggle out of the count, and active counts a selection="single" group that picks what a list
shows, while its choice is not the default one.
Search#
A ToolbarSearch's field takes the bar's size, as its commands do, down to the xs of a
block's header, so on a fine pointer a bar with a search is as tall as one without. A field of
your own in its place, given as its children, takes the size too, from useToolbar(), and so
do the buttons inside it, as the log's search does with its steps and modes. On touch a field is
taller, to hold its larger text, and the bar keeps that height while the icon stands in for it.
A ToolbarSearch with a query never becomes its icon. Pressing the icon opens the field again at
its narrowest, moving other commands into the menu to make room; only when nothing else could make
room does the field take the whole bar, with a button back. The field stays one element through all
of this, so its caret and an input method's composition survive.
The keyboard#
A toolbar's commands are one Tab stop, and the arrow keys move between them, wrapping at the ends and following the reading direction; a command in the menu is skipped. Tab comes back to the command the focus last left. A search's field is a Tab stop of its own, so its arrow keys move its caret, and Tab meets it where it stands, before the commands or after them.
A command that only one layout of the page has, such as a Back that a phone needs and a window with the list beside it does not, is hidden there by a class of its own. That is not fitting the bar to its room: the bar counts the command as absent, and Tab and the arrow keys pass it by.
Before it is measured#
A prerendered page draws every command first. What does not fit wraps onto a line that is cut off
rather than showing half a button, and the bar lays itself out once the page runs, which may move
it once. A ⋯ that only holds overflow appears then; one with commands of its own is there from
the start.
In the demos
- ReleasesPick a row and the list's bar becomes what to do with the selection. Narrow the window: the filters drop into the ⋯ first, and Deploy stays to the last.
- GalleryNarrow the window: Filter components narrows before anything else on the bar moves. Each tile's lid keeps the export's name while the commands a viewer lends it stand after the name in a block header's order, Source before Copy on PatchView.
- AdminMembers' bar holds a search, the Role filter and Export CSV. Narrow the window and the search gives way to its icon first.
- TasksNarrow the window: List and Board fold into a menu of the view, the search gives way to its icon, then the filters move into the toolbar's ⋯, the last first, while New task… keeps its place. A filter set from there is counted on the ⋯, and marked in its menu.
- MailThe thread's toolbar is one Tab stop, walked with the arrow keys. Star keeps the far end past a spacer, and More actions holds Forward and Copy link, below whatever the bar has no room for.