SpeedDial
Since 0.1.0-alpha.22A floating button that opens a line of actions, such as the things a page can create: a speed dial (Material's name; a FAB menu in other libraries). The button sits in a corner of the window like FloatingButton and turns into a close button while the actions show.
Things to create
Set Label to name the button, and give each SpeedDialAction an Icon and a Label, shown beside it. An action is a link (Href), a form post (Submit) or C# (OnClick). The button spins into a close button while the actions show; SpinIcon="false" swaps the icons without turning.
Static
Preview
Code
NavigationManager Navigation
@* The things an invoices page can create, from one button in the corner. Each action is 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>
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>
<SpeedDial Label="Create">
<SpeedDialAction Icon="Lucide.FileText" Label="Invoice" Href="To("invoice")" />
<SpeedDialAction Icon="Lucide.UserPlus" Label="Customer" Href="To("customer")" />
<SpeedDialAction Icon="Lucide.Package" Label="Product" Href="To("product")" />
</SpeedDial>
{
[SupplyParameterFromQuery(Name = "create")] private string? Created { get; set; }
private string To(string what) => Navigation.GetUriWithQueryParameter("create", what);
}Add this example to a page with the izzy CLI:
izzy add component SpeedDial --at <file>:<line>Icons that open on hover
To show only the icons, with the labels as tooltips, set ShowLabels="false". To open as the pointer comes over the button, set OpenOn="SpeedDialTrigger.Hover"; a click or tap still opens it. Direction opens the actions down, or toward the start or end, Icon and OpenIcon change the button's icons, and Round makes it round, as here.
Static
Preview
Code
NavigationManager Navigation
@* A document's tools as icons that open as the pointer comes over the button; each label is its
tooltip. A click or tap opens them too. *@
<Stack Gap="4" Padding="4">
<Heading Level="1" Size="TextSize.Xl">Q3 report</Heading>
if (Done is not null)
{
<Alert Status="Status.Info">Done.</Alert>
}
<TextBlock Color="Color.Muted">Revenue grew 12% over the quarter, led by the new annual plans.</TextBlock>
</Stack>
<SpeedDial Label="Document tools" Icon="Lucide.Ellipsis" OpenOn="SpeedDialTrigger.Hover" ShowLabels="false" Round>
<SpeedDialAction Icon="Lucide.Share2" Label="Share" Href="To("Shared")" />
<SpeedDialAction Icon="Lucide.Printer" Label="Print" Href="To("Printed")" />
<SpeedDialAction Icon="Lucide.Copy" Label="Duplicate" Href="To("Duplicated")" />
</SpeedDial>
{
[SupplyParameterFromQuery(Name = "done")] private string? Done { get; set; }
private string To(string what) => Navigation.GetUriWithQueryParameter("done", what);
}Details
It's built on the Popover API, as Menu is: the button opens the actions with no script, and Escape or a click outside closes them. The labels show beside the actions (ShowLabels); with ShowLabels="false", or opening toward the start or end, the actions are icons and the labels their tooltips. OpenOn="Hover" opens it as the pointer comes over the button, with script.
Parts
Written inside SpeedDial. The API page lists their parameters.
SpeedDialAction: one action of aSpeedDial: a round icon with its label beside it, or as its tooltip.
Mode support
| Feature | Static | Interactive |
|---|---|---|
| Opens and closes with JavaScript off | Yes | Yes |
| Actions are links, form posts or C# | Yes | Yes |
| Opens on hover (OpenOn) | Yes | Yes |
| Arrow keys between the actions | Yes | Yes |
Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.
Without JavaScript
Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off. With JavaScript off, the button opens and closes the actions, but arrow keys don't move between them, and OpenOn="Hover" opens on click.
Accessibility
- The button is named by
Label, and says whether the actions show (aria-expanded). - With script, the actions are a
menuofmenuitems named by the button; with JavaScript off, they're plain links and buttons. - Each action is named by its
Label, shown or as its tooltip. - Opening it focuses the first action, nearest the button; Escape or a choice brings focus back.
Keyboard navigation
On the button
| Press this key | To do this |
|---|---|
| Enter or Space | Open the actions at the first |
| Up | Open the actions at the nearest (Down, Left or Right when they open that way) |
In the actions
| Press this key | To do this |
|---|---|
| Up or Down | Move away from the button and back toward it, wrapping (Left and Right when they open toward the start or end) |
| Home or End | Go to the first or last |
| Letters | Jump to the next action starting with them |
| Enter or Space | Choose one |
| Escape | Close and go back to the button |
| Tab | Close the actions and move on |
Parameters
| Prop | Type | Default |
|---|---|---|
LabelThe button's name, such as "Create": what the actions have in common. | string | Required |
IconThe button's icon. | IconData? | computed |
OpenIconThe button's icon while the actions show. | IconData? | computed |
PlacementWhere the button sits. | FloatPlacement | FloatPlacement.BottomEnd |
AccentThe button's color. | Accent | Accent.Primary |
RoundMakes the button round. | bool | false |
SpinIconSpins the button's icon into OpenIcon as the actions open, and back (the default). | bool | true |
DirectionWhich way the actions open from the button. | SpeedDialDirection | SpeedDialDirection.Up |
OpenOnWhat opens it: a click (the default), or the pointer coming over the button. | SpeedDialTrigger | SpeedDialTrigger.Click |
ShowLabelsShows each action's label beside it (the default), clear on touch screens and with JavaScript off. | bool | true |
PanelWidthThe width of the menu panel, such as Length.Rem(16) for a column of long labels. | Length? | computed |
ChildContentThe MenuItems, MenuGroups and MenuDividers. | RenderFragment? | |
@bind-OpenWhether it is open. | bool | false |
IdThe element id. | string? |
Plus 17 item props and 4 common props.
Full APISee also
- FloatingButton: floats the page's main action in a corner of the window.
- Menu: opens a popover menu of links, form posts and actions.