Adaptability
Since 0.1.0-alpha.13What moves first
When a toolbar runs out of room, its items move into the … menu one at a time. To keep an item in the bar longer, give it a higher Priority; items default to 0. To fix where an item goes, set its Overflow: Never keeps it in the bar, such as the main action, and Always puts it only in the menu.
Static
Preview
Code
<Card Size="ControlSize.Sm" Width="Length.Full">
<CardBody>
<Toolbar Label="File">
<ToolbarButton StartIcon="Lucide.Upload" Accent="Accent.Primary" Variant="ButtonVariant.Solid" Overflow="ToolbarOverflow.Never">Upload</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Share2" Priority="1">Share</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Pencil">Rename</ToolbarButton>
<ToolbarButton StartIcon="Lucide.FolderInput">Move</ToolbarButton>
<ToolbarSeparator />
<ToolbarButton StartIcon="Lucide.Printer" Overflow="ToolbarOverflow.Always">Print</ToolbarButton>
<ToolbarButton StartIcon="Lucide.FileClock" Overflow="ToolbarOverflow.Always">Version history</ToolbarButton>
</Toolbar>
</CardBody>
</Card>Items move in this order:
- Items with a lower
Prioritymove before items with a higher one. - Among items with the same priority, the items at the start move first, beginning with the one nearest the middle.
- Then the items at the end move, again beginning with the one nearest the middle. The main action at the far end moves last.
A ToolbarSeparator leaves the bar when nothing is left on one side of it.
By screen width
An item's Overflow can change with the screen's width, to keep a phone's bar for the main actions. Set it per breakpoint: with new() { Base = ToolbarOverflow.Always, Sm = ToolbarOverflow.Auto }, the item is in the … menu on a phone, and from 640px up it stays in the bar while there's room.
Preview
Code
@* An invoice's actions. Download PDF and Print are always in the … menu on a phone, and in the bar
from 640px up while there's room, so a phone's bar keeps Edit and Send. *@
<Stack Gap="4" Padding="4">
<Heading Level="1" Size="TextSize.Xl">Invoice 1052</Heading>
<Toolbar Label="Invoice">
<ToolbarButton StartIcon="Lucide.Pencil" Href="#">Edit</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Copy" Href="#">Duplicate</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Download" Href="#" Overflow="new() { Base = ToolbarOverflow.Always, Sm = ToolbarOverflow.Auto }">Download PDF</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Printer" Href="#" Overflow="new() { Base = ToolbarOverflow.Always, Sm = ToolbarOverflow.Auto }">Print</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Send" Href="#" Accent="Accent.Primary" Variant="ButtonVariant.Solid" Position="ToolbarPosition.End" Overflow="ToolbarOverflow.Never">Send</ToolbarButton>
</Toolbar>
</Stack>The grid's Columns and Export tools work this way by default.
Floating on a phone
A page's main action can leave the bar on a phone and float in the screen's bottom corner, where the thumb reaches it. Set FloatBelow="Breakpoint.Sm" on the button. The button needs a StartIcon, which the floating button shows, and its text names the floating button. When the text isn't plain text, set FloatLabel.
Preview
Code
NavigationManager Navigation
@* An invoices page's main action: in the toolbar on wider screens, a floating button in the corner
on a phone. It's a link, so it works on static pages too; here it stays on this page. *@
<Stack Gap="4" Padding="4">
<Heading Level="1" Size="TextSize.Xl">Invoices</Heading>
<Toolbar Label="Invoices">
<ToolbarButton StartIcon="Lucide.ListFilter" Href="#">Filter</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Download" Href="#">Export</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Plus" Href="To("invoice")" Accent="Accent.Primary" Variant="ButtonVariant.Solid" Position="ToolbarPosition.End"
FloatBelow="Breakpoint.Sm">New invoice</ToolbarButton>
</Toolbar>
if (Created is not null)
{
<Alert Status="Status.Info">New Created.</Alert>
}
<Stack Gap="2">
foreach (var i in Enumerable.Range(1, 12))
{
<Card Padding="3">Invoice (1040 + i)</Card>
}
</Stack>
</Stack>
{
[SupplyParameterFromQuery(Name = "create")] private string? Created { get; set; }
private string To(string what) => Navigation.GetUriWithQueryParameter("create", what);
}The floating button keeps the item's link, form post or OnClick. A grid's DataGridAdd takes FloatBelow too, and so does a Button in a page header's actions; see Actions that float on a phone.
When more than one item floats below the same width, they share a speed dial. Set the toolbar's FloatLabel to name it; it defaults to "Actions".
Preview
Code
NavigationManager Navigation
@* Two things to create, both floating on a phone: they share one speed dial, named by the
toolbar's FloatLabel. Each action is a link that stays on this page. *@
<Stack Gap="4" Padding="4">
<Heading Level="1" Size="TextSize.Xl">Invoices</Heading>
<Toolbar Label="Invoices" FloatLabel="Create">
<ToolbarButton StartIcon="Lucide.Download" Href="#">Export</ToolbarButton>
<ToolbarButton StartIcon="Lucide.UserPlus" Href="To("customer")" Position="ToolbarPosition.End"
FloatBelow="Breakpoint.Sm">New customer</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Plus" Href="To("invoice")" Accent="Accent.Primary" Variant="ButtonVariant.Solid" Position="ToolbarPosition.End"
FloatBelow="Breakpoint.Sm">New invoice</ToolbarButton>
</Toolbar>
if (Created is not null)
{
<Alert Status="Status.Info">New Created.</Alert>
}
<Stack Gap="2">
foreach (var i in Enumerable.Range(1, 12))
{
<Card Padding="3">Invoice (1040 + i)</Card>
}
</Stack>
</Stack>
{
[SupplyParameterFromQuery(Name = "create")] private string? Created { get; set; }
private string To(string what) => Navigation.GetUriWithQueryParameter("create", what);
}Icons before the menu
A toolbar can show its buttons as icons only before it moves anything into the … menu. Set CollapseLabels, and buttons and menus with a StartIcon all drop their text at once. The text stays for screen readers and as the tooltip.
Static
Preview
Code
<Card Size="ControlSize.Sm" Width="Length.Full">
<CardBody>
<Toolbar Label="Insert" CollapseLabels>
<ToolbarButton StartIcon="Lucide.Heading">Heading</ToolbarButton>
<ToolbarButton StartIcon="Lucide.List">List</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Quote">Quote</ToolbarButton>
<ToolbarMenu Label="Media" StartIcon="Lucide.Image">
<MenuItem Icon="Lucide.Image">Image</MenuItem>
<MenuItem Icon="Lucide.Video">Video</MenuItem>
</ToolbarMenu>
<ToolbarButton StartIcon="Lucide.Send" Accent="Accent.Primary" Variant="ButtonVariant.Solid" Position="ToolbarPosition.End" Overflow="ToolbarOverflow.Never">Publish</ToolbarButton>
</Toolbar>
</CardBody>
</Card>Narrow the window to see it. Once the icons alone don't fit, items move into the menu as before. An item with Overflow="ToolbarOverflow.Never" keeps its text.
Wrapping instead
A toolbar that wraps shows every item, on as many rows as it needs, with no … menu. It suits a toolbar where every control must stay visible. Set Wrap.
Static
Preview
Code
<Card Size="ControlSize.Sm" Width="Length.Full">
<CardBody>
<Toolbar Label="Insert" Wrap>
<ToolbarButton StartIcon="Lucide.Heading">Heading</ToolbarButton>
<ToolbarButton StartIcon="Lucide.List">List</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Quote">Quote</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Code">Code</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Table">Table</ToolbarButton>
<ToolbarButton StartIcon="Lucide.Image">Image</ToolbarButton>
</Toolbar>
</CardBody>
</Card>