Buttons

ButtonControl

Run actions, submit forms and open dropdowns with one native button.

Overview

ButtonControl is a Blazor button: users click it to run an action, submit a form or open a dropdown panel. It renders a native <button>, so Tab, Enter and Space behave as the browser intends and ButtonType="submit" sends its form. Set the look with a btn-* class, an IconCss icon and the --fx-btn-* color variables; SaveButtonControl, CancelButtonControl and the pill-shaped RoundedButtonControl build on it.

Examples

#Actions on a leave request

Review the leave request: the actions pair a btn-* color with an IconCss icon (Team calendar puts its arrow after the caption), and Disabled follows the request's status, so only the actions that make sense stay live. Print is icon-only, named with aria-label; Small buttons adds btn-sm.

LR-0107 · Vacation, Dec 14 to 18
Hermione Ranger, Reservations, 5 working days
Pending

Last action: none yet

#Submit, busy and cancel

Add a colleague to cover the leave: type a name and press Enter or Save. ButtonType="submit" sends the form, and IsSaving disables the button and reads "Saving…" until the save returns. The spinner it shows meanwhile is this page's CSS in place of the library's pulse: the page turns off the animation on .fx-save-button--saving, hides the disk icon and draws a turning ring in ::before. Cancel clears the box. The colleagues covering are RoundedButtonControl pills: click one to remove it.

Add a colleague to cover for Hermione Ranger

Documentation

ParameterTypeDefaultDescription
ChildContentRenderFragment?—The label: text or any markup, after the icon.
CssClassstring?nullAdded after fx-button: a color class such as btn-primary, and btn-sm or btn-lg.
IconCssstring?nullClasses for an icon before the label, such as bi bi-save; any icon font works.
DisabledboolfalseNative disabled: no clicks, no hover or pressed look, drawn at 60% opacity.
ButtonTypestring"button"Native type: button, submit or reset. The default never submits a form.
Titlestring?nullNative tooltip. An icon-only button also needs aria-label.
Stylestring?nullInline style; handy for setting --fx-btn-* variables on one button.
TabIndexint?nullNative tabindex.
AutoFocusboolfalseFocuses the button once, on the first render where it is enabled.
BareStyleboolfalseLeaves out fx-button, so only your CssClass styles the button.
StopPropagationboolfalseStops the click reaching ancestors that also handle clicks.
PreventMouseDownDefaultboolfalseKeeps focus where it was when the button is pressed, so an editor keeps its selection.
DropDownContentRenderFragment?nullMakes the button a dropdown trigger: a click shows this content in a panel beneath it, and a click outside closes it.
DropDownCssClassstring?nullExtra class on the dropdown panel.
(unmatched attributes)Dictionary<string,object>—Written on the button, such as id, name, form, accesskey, aria-* and data-*. The button's own class, type, disabled, title, tabindex and style win.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.