Skip to content

Buttons

ActionButton

Bit.BlazorUI

ActionButton is the lightweight, icon-first flavor of button: a transparent box with a colorized icon and plain text, made for inline commands like New, Edit, or Share. It renders as a native button or, given an Href, as a link with hardened navigation attributes, and ships with a full loading state (AutoLoading with double-click protection, loading label, delayed spinner) and accessible disabled and loading semantics.

Usage

Every example is live. Open its code to see exactly what produced the component running underneath.

Basic

A native button with the icon first and the content beside it. The icon is optional, and the content is any markup, not just text. IsEnabled false dims the button and suppresses its click. IconOnly drops the content and squares the box off into an icon button, so give it an AriaLabel to keep a name for screen readers.

IconPosition

IconPosition moves the icon to the other side of the content. End suits forward actions like Next or Open, and the spinner takes the same side while loading.

Href

An Href renders a real anchor instead of a button, so open-in-new-tab, the context menu, and the link announcement all keep working. Target picks where it opens; with _blank, rel="noopener" is added automatically. A disabled or loading link drops its href rather than rendering an invalid disabled attribute.



Download saves the resource instead of navigating to it: an empty value keeps the server-provided file name, any other value suggests one. Browsers honor it only for same-origin, blob:, and data: URLs.



Rel declares the relationship with the destination. It is a flags enum (BitLinkRels), so values combine with |. It is emitted for real navigations only, never for empty or hash-only hrefs.

ButtonType

Inside an EditForm the button defaults to submit, outside it to button; ButtonType overrides that. FormId ties a button placed outside the form to it through the native form attribute.




FullWidth & NoWrap

FullWidth stretches the button across its container and lets the content fill the room, so an end-positioned icon lands on the far edge: the familiar navigation row with the label on one side and a chevron on the other.



A label longer than the room it has been given wraps onto a second line, which keeps it readable but changes the height of the row. NoWrap keeps it on one line and ends it with an ellipsis instead. Only the drawing of the label is cut short - the button is still named by the whole of it, so a screen reader reads it out in full - but a sighted user is left with the ellipsis, so wrap the button in a BitTooltip, which shows the full label to the pointer and to the keyboard alike and is dismissed with Escape. A Title is shown to the pointer only, so it cannot be the disclosure on its own. The tooltip declares no relationship of its own here, since the button already carries the same text as its accessible name.

Loading

IsLoading swaps the icon for a spinner, marks the button busy for assistive technologies, and ignores further clicks. It is two-way bindable.




AutoLoading enters and leaves the loading state around an async OnClick, even when it throws. LoadingLabel replaces the content with a progress message and announces it to screen readers. LoadingDelay holds the spinner back for the given milliseconds so quick operations do not flash, while the click-guard still applies from the first moment.



Clicks are ignored while loading, which is what keeps a submit or a payment from firing twice. Reclickable lets them through when repeats are meaningful. Click each counter rapidly to compare.



LoadingTemplate takes over the whole loading visual. Declare the normal content through Body so both templates fit on one button.


Underlined

Underlined draws a hyperlink-style underline under the text that thickens on hover, where color alone is not enough of a cue.

Open GitHub


A standalone button keeps the control height and padding of its size, so it lines up with the other controls beside it. To put one on the line of a sentence instead, drop both: --bit-ActionButton-min-height: 0; --bit-ActionButton-padding: 0.

Everything here is covered by the terms of service , which you accept by continuing.

Events

OnClick fires on mouse, touch, and keyboard activation, never while disabled or loading. Inside another clickable surface, such as a row or a card, set StopPropagation so the container's handler stays quiet.


Row clicks: 0  |  Button clicks: 0

Accessibility

Title is a native tooltip the browser shows on hover only, so it never replaces an accessible name: an icon-only button also needs an AriaLabel, kept consistent with it.



AriaDescription is a longer sentence rendered as visually hidden text the button points at through aria-describedby. It is read after the name, not as part of it, which makes it the place for what the user would want to know before acting: the size of a file, what a page will ask for.



A disabled button normally leaves the tab order, so keyboard and screen reader users can miss that the action exists. AllowDisabledFocus conveys the state through aria-disabled instead of the native attribute: the button stays focusable and discoverable, its click stays suppressed, and the focus ring is drawn in the muted disabled color. Tab through the two buttons to feel the difference.



FocusAsync moves the keyboard focus onto the button from code, for the moment a dialog opens, a step finishes, or an error sends the user back to the action that failed. AutoFocus does the same on the first render, and neither steals the focus from a button that is hidden with AriaHidden or disabled without AllowDisabledFocus.

Cascading parameters

BitParams carries a BitActionButtonParams down to every action button under it, so a toolbar, a card, or a whole page sets the shared look and the shared link behavior once instead of on every button. What it carries is a default and not an override: a button that writes a parameter for itself keeps its own value, and only what it left unset is filled in from the cascade, which is what lets one button step out of the group it is in without the group having to know about it. Every parameter of the component is on the params object, and each of them is filled in on its own, so a button can take its IconPosition from the cascade and its Underlined from its own markup.


Color

Color paints the icon and the spinner at rest, takes over the text on hover and press, and picks the focus ring, all from the current theme. Beyond the semantic roles, the background, foreground, and border roles suit buttons that must blend into a surface, such as the ones on the dark panel below.
Using the Color parameter and its value of type BitColor enum:





















Disabled: every role mutes to the same lightness with only a trace of its hue, so the inert state carries the same weight whatever the color and never reads as a dimmed accent that is still clickable.





External Icons

Besides the built-in Fluent set behind IconName, Icon renders any CSS-class icon library such as FontAwesome or Bootstrap Icons: pass the raw classes, or use the BitIconInfo helpers (Css, Fa, Bi). When both are set, Icon wins. Reference the library's stylesheet in your app.


FontAwesome:



Bootstrap:



IconUrl renders an image in the icon's slot at the icon's size, for a logo or a custom asset no font provides. The spinner still takes its place while loading.

Size

Each preset scales the text, the icon, the spinner, and the padding together. Medium is the default; Small suits dense toolbars and table rows, Large prominent standalone actions.
Using the Size parameter and its value of type BitSize enum:

Style & Class

Style and Class land on the root; Styles and Classes reach every part on its own: the root, the icon, the content, the loading label, and the spinner. Prefer Classes when your CSS should own states such as hover and focus, which inline styles cannot express.
Using the Styles and Classes parameters and their value of BitActionButtonClassStyles class:



The button also reads a set of CSS variables off its root for what no parameter covers. They inherit, so a value on :root or any ancestor re-skins every button below it, and one on the Style of an instance re-skins that one alone.

CSS variables:


Set once on an ancestor, inherited by every button inside it:

RTL

Dir set to Rtl mirrors the button for right-to-left languages: the icon and the content swap sides and the padding follows. Set it per button, or let it flow from an ancestor through the cascading direction value.

CSS variables

The public custom properties this component reads off its root, for what no parameter covers.

Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property: set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it, or on the Style of one instance to restyle that one alone. Leave a variable unset and the component falls back to the theme token beside it.

BitActionButton CSS variables

Name Default value Description
--bit-ActionButton-color --bit-clr-fg-pri Text color in the rest state, where the role color reaches the icon alone. The hover and pressed states paint the text through their own override variables, so this one does not apply there.
--bit-ActionButton-icon-color The Color role's main color Icon and spinner color at rest.
--bit-ActionButton-hover-color The Color role's hover color Text and icon color while hovered (pointer devices only).
--bit-ActionButton-active-color The Color role's active color Text and icon color while pressed.
--bit-ActionButton-disabled-color --bit-clr-fg-dis (text), the Color role's disabled text color (icon) Text and icon color when IsEnabled is false; also the focus ring color of a disabled button kept focusable with AllowDisabledFocus.
--bit-ActionButton-focus-color The Color role's focus color Color of the keyboard focus ring.
--bit-ActionButton-background transparent Background at rest, and the fallback of the two state backgrounds below.
--bit-ActionButton-hover-background --bit-ActionButton-background Background while hovered. A translucent tint of the role color, such as color-mix(in srgb, var(--bit-clr-pri) 12%, transparent), gives the Material-style state layer.
--bit-ActionButton-active-background --bit-ActionButton-hover-background Background while pressed.
--bit-ActionButton-radius --bit-shp-radius-button Corner radius of the box, which the backgrounds and the focus ring follow.
--bit-ActionButton-min-height Per Size: --bit-siz-ctrl-sm / -md / -lg Smallest height of the box, which is what lines an action button up with the other controls of its size and keeps the smallest one above the 24px minimum pointer target of WCAG 2.2. It is a floor, not a height: a wrapped label still grows the box. Set it to 0 for a button that has to sit on the line of the running text around it.
--bit-ActionButton-padding Per Size: the control's y padding and one step below the standalone button's x padding Padding of the box. Set it to 0 for a button that sits flush inside running text or a table cell.
--bit-ActionButton-gap spacing(1) Room between the icon (or spinner) and the content.
--bit-ActionButton-font-size Per Size: --bit-tpg-fs-xs / -sm / -md Font size of the text and the loading label.
--bit-ActionButton-icon-size Per Size: --bit-siz-icon-sm / -md / -lg Size of the icon, the IconUrl image and the spinner, which share one slot so entering the loading state moves nothing.

API

Every parameter, public member, sub-class and enum this component exposes.

BitActionButton parameters

Name Type Default value Description
AllowDisabledFocus bool false Keeps the disabled action button focusable and discoverable by assistive technologies, conveying the disabled state using aria-disabled instead of the native disabled attribute.
AriaDescription string? null Detailed description of the button for the benefit of screen readers, rendered as visually hidden text beside the button and read after its name. An aria-describedby written on the component by hand is kept and this description is added to it.
AriaHidden bool false If true, adds an aria-hidden attribute instructing screen readers to ignore the button.
AutoFocus bool false If true, the action button automatically receives focus when the page renders (rendered as the autofocus attribute).
AutoLoading bool false If true, enters the loading state automatically while awaiting the OnClick event and prevents subsequent clicks by default.
ButtonType BitButtonType null The type of the button element; defaults to submit inside an EditForm otherwise button.
Body RenderFragment? null Alias for ChildContent, the custom body of the action button (text and/or any render fragment).
ChildContent RenderFragment? null The custom body of the action button (text and/or any render fragment).
Classes BitActionButtonClassStyles? null Custom CSS classes for the root, icon, content, loading label, and spinner of the action button.
Color BitColor? null The color role of the action button. At rest it paints the icon and the spinner while the text keeps the neutral foreground; on hover and press it takes over the text as well, and it also picks the focus ring color.
Download string? null The value of the download attribute of the link rendered by the button when the Href parameter is provided. Instructs the browser to download the linked resource instead of navigating to it, using the provided value (if any) as the suggested file name.
EditContext EditContext? null The EditContext, which is set if the button is inside an EditForm. The value is coming from the cascading value provided by the EditForm.
FormId string? null The id of the form element that the action button is associated with (rendered as the form attribute). Allows a submit/reset button to be placed outside of its form element.
FullWidth bool false Stretches the action button across the full available width. The icon and the content stay next to each other with IconPosition.Start; IconPosition.End reverses the inner wrapper, so the growing content pushes them to the opposite edges.
Href string? null The value of the href attribute of the link rendered by the button. If provided, the component will be rendered as an anchor tag instead of button.
Icon BitIconInfo? null Gets or sets the icon to display using custom CSS classes for external icon libraries. Takes precedence over IconName when both are set.
IconName string? null Gets or sets the name of the icon to display from the built-in Fluent UI icons.
IconOnly bool false Gets or sets a value indicating whether only the icon is displayed, without accompanying text. The button then takes the square shape of an icon button, so give it an AriaLabel: with the content dropped it has no text left to name it with.
IconPosition BitIconPosition? null Gets or sets the position of the icon relative to the component's content.
IconUrl string? null The url of a custom image to render as the icon of the action button, used when neither Icon nor IconName is set.
IsLoading bool false Determines whether the action button is in loading mode or not (two-way bindable).
LoadingDelay int 0 The delay in milliseconds before the loading indicator appears after entering the loading state, useful to avoid a spinner flash for fast operations. The click-guard of the loading state applies immediately regardless of this delay.
LoadingLabel string? null The text to show next to the spinner while the action button is in the loading state, replacing the button body. It is also announced by screen readers through a status live region when the loading state starts.
LoadingTemplate RenderFragment? null The custom template used to replace the default loading indicator inside the action button in the loading state.
NoWrap bool false Keeps the content of the action button on a single line and ends it with an ellipsis where it does not fit. It has no effect on a button left to hug its content, which is never narrower than its text.
OnClick EventCallback<MouseEventArgs> Gets or sets the callback that is invoked when the component is clicked.
Reclickable bool false Enables re-clicking the action button while it is in the loading state. By default, clicks are ignored while the button is loading to protect against double submissions.
Rel BitLinkRels? null Gets or sets the relationship type between the current element and the linked resource, as defined by the link's rel attribute.
Size BitSize? null Sets the preset size (Small, Medium, Large) for typography and padding of the action button.
StopPropagation bool false If true, stops the propagation of the click event to the parent elements. Useful when the action button is placed inside clickable containers like rows or cards.
Styles BitActionButtonClassStyles? null Gets or sets the custom CSS inline styles to apply to the action button component.
Target string? null Gets or sets the name of the target frame or window for the navigation action when the action button renders as an anchor (by providing the Href parameter). When set to _blank and no opener-related Rel is provided, noopener is added to the rel attribute automatically.
Title string? null The tooltip to show when the mouse is placed on the button.
Underlined bool false Underlines the text of the action button, which thickens on hover, for the link-style use inside running text.

BitActionButton public members

Name Type Default value Description
FocusAsync ValueTask Gives focus to the root element of the action button.

BitComponentBase parameters

Name Type Default value Description
AriaLabel string? null Gets or sets the accessible label for the component, used by assistive technologies.
Class string? null Gets or sets the CSS class name(s) to apply to the rendered element.
Dir BitDir? null Gets or sets the text directionality for the component's content.
ForceAnimation bool false Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested.
HtmlAttributes Dictionary<string, object> new Dictionary<string, object>() Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters.
Id string? null Gets or sets the unique identifier for the component's root element.
IsEnabled bool true Gets or sets a value indicating whether the component is enabled and can respond to user interaction.
Style string? null Gets or sets the CSS style string to apply to the rendered element.
TabIndex string? null Gets or sets the tab order index for the component when navigating with the keyboard.
Visibility BitVisibility BitVisibility.Visible Gets or sets the visibility state (visible, hidden, or collapsed) of the component.

BitComponentBase public members

Name Type Default value Description
UniqueId Guid Guid.NewGuid() Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed.
RootElement ElementReference Gets the reference to the root HTML element associated with this component.

BitActionButtonClassStyles properties

Defines per-part CSS class/style values for BitActionButton.

Name Type Default value Description
Root string? null Custom class or style applied to the root element of the BitActionButton.
Icon string? null Custom class or style applied to the icon element of the BitActionButton (the glyph, or the image rendered for IconUrl).
Content string? null Custom class or style applied to the content container of the BitActionButton.
LoadingLabel string? null Custom class or style applied to the loading label element of the BitActionButton.
Spinner string? null Custom class or style applied to the loading spinner element of the BitActionButton.

BitIconInfo properties

Name Type Default value Description
Name string? null Gets or sets the name of the icon.
BaseClass string? null Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty.
Prefix string? null Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty.

BitButtonType enum

Name Value Description
Button 0 The button is a clickable button.
Submit 1 The button is a submit button (submits form-data).
Reset 2 The button is a reset button (resets the form-data to its initial values).

BitColor enum

Name Value Description
Primary 0 Info Primary general color.
Secondary 1 Secondary general color.
Tertiary 2 Tertiary general color.
Info 3 Info general color.
Success 4 Success general color.
Warning 5 Warning general color.
SevereWarning 6 SevereWarning general color.
Error 7 Error general color.
PrimaryBackground 8 Primary background color.
SecondaryBackground 9 Secondary background color.
TertiaryBackground 10 Tertiary background color.
PrimaryForeground 11 Primary foreground color.
SecondaryForeground 12 Secondary foreground color.
TertiaryForeground 13 Tertiary foreground color.
PrimaryBorder 14 Primary border color.
SecondaryBorder 15 Secondary border color.
TertiaryBorder 16 Tertiary border color.

BitSize enum

Name Value Description
Small 0 The small size button.
Medium 1 The medium size button.
Large 2 The large size button.

BitIconPosition enum

Name Value Description
Start 0 Icon renders before the content (default).
End 1 Icon renders after the content.

BitVisibility enum

Name Value Description
Visible 0 The content of the component is visible.
Hidden 1 The content of the component is hidden, but the space it takes on the page remains (visibility:hidden).
Collapsed 2 The component is hidden (display:none).

BitDir enum

Name Value Description
Ltr 0 Ltr (left to right) is to be used for languages that are written from the left to the right (like English).
Rtl 1 Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic).
Auto 2 Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element.

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.