Buttons
Button
BitButton triggers an action or navigates when the user activates it. It renders a native button, or an anchor when an Href is provided, and offers Fill, Outline, and Text variants across a full palette of semantic colors and sizes. It supports start/end icons, an optional secondary line of text, and loading states that stack a spinner over the content so the box keeps the size and the accessible name it had before the click. It also stretches to the full width of its container, or leaves the flow entirely as a floating (FAB) button pinned to the viewport or to its container and draggable by pointer or by the arrow keys, and a BitParams ancestor carrying a BitButtonParams sets the defaults of every button in a subtree. Its defaults are accessibility-first: disabled buttons stay focusable through aria-disabled, an icon-only button keeps its label as its accessible name, the loading label is announced from a live region rather than folded into the button's name, an external link gets rel='noopener' on its own, and every state is re-established in system colors under Windows High Contrast.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Variant & Rounded
--bit-Button-radius set on the button or on an ancestor.
Icon
Loading
aria-busy and aria-disabled - busy alone would report progress without reporting
that the press now does nothing. LoadingLabel adds text beside the spinner - announced from a live
region rather than folded into the button's name - and LoadingLabelPlacement places it.
Href
Form & button type
formaction, formmethod, formnovalidate - have no parameter of their
own: write them on the component and they are passed through to the button.
Templates
Events
FullWidth & NoWrap
FixedColor
Float & Draggable
In the beginning, there is silence a blank canvas yearning to be filled, a quiet space where creativity waits to awaken. These words are temporary, standing in place of ideas yet to come, a glimpse into the infinite possibilities that lie ahead. Think of this text as a bridge, connecting the empty spaces of now with the vibrant narratives of tomorrow. It whispers of the stories waiting to be told, of the thoughts yet to be shaped into meaning, and the emotions ready to resonate with every reader.
In this space, potential reigns supreme. It is a moment suspended in time, where imagination dances freely and each word has the power to transform into something extraordinary. Here lies the start of something new - an opportunity to craft, inspire, and create. Whether it's a tale of adventure, a reflection of truth, or an idea that sparks change, these lines are yours to fill, to shape, and to make uniquely yours. The journey begins here, in this quiet moment where everything is possible.
Accessibility
aria-describedby. It is read after the name rather than as part of it, which makes it the place
for what the user wants to know before acting: the size of a file, what the next page will ask for. An
aria-describedby written on the component by hand is kept and this description is added to it.
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. It also keeps answering the
pointer, so its Title still explains why it cannot be pressed. Tab through the two below to feel the
difference, and hover the first for its reason.
Cascading parameters
Color
External Icons
Size
Style & Class
RTL
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.
BitButton CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-Button-color | Per variant: --bit-clr-pri-text when filled, --bit-clr-pri otherwise | Foreground (text and icon) in the rest state. FixedColor holds this color through hover and press as well. The Color parameter wins over it. |
| --bit-Button-background | --bit-clr-pri when filled, transparent otherwise | Background in the rest state. The Color parameter wins over it in Fill; the transparent background of Outline and Text is its alone. |
| --bit-Button-border-color | --bit-clr-pri when filled or outlined, transparent otherwise | Border color in the rest state. The border is drawn on every variant, so a Text button can take one without changing its size. The Color parameter wins over it, except over the transparent border of Text. |
| --bit-Button-hover-color | --bit-clr-pri-text, and the rest color for the Fill variant | Foreground while hovered (pointer devices only). The Color parameter wins over it. |
| --bit-Button-hover-background | --bit-clr-pri-hover | Background while hovered (pointer devices only). The Color parameter wins over it. |
| --bit-Button-hover-border-color | The rest border color, and the hover background for the Fill variant | Border color while hovered (pointer devices only). The Color parameter wins over it, except over the transparent border of Text. |
| --bit-Button-active-color | As the hover foreground | Foreground while pressed. The Color parameter wins over it. |
| --bit-Button-active-background | --bit-clr-pri-active | Background while pressed. The Color parameter wins over it. |
| --bit-Button-active-border-color | As the hover border color | Border color while pressed. The Color parameter wins over it, except over the transparent border of Text. |
| --bit-Button-disabled-color | --bit-clr-pri-dis-text | Foreground when disabled. It also draws the focus ring of a disabled button that AllowDisabledFocus keeps in the tab order. The Color parameter wins over it. |
| --bit-Button-disabled-background | --bit-clr-pri-dis when filled, transparent otherwise | Background when disabled. The Color parameter wins over it in Fill; the transparent background of Outline and Text is its alone. |
| --bit-Button-disabled-border-color | As the disabled background | Border color when disabled. The Color parameter wins over it, except over the transparent border of Text. |
| --bit-Button-focus-color | --bit-clr-pri-focus | Color of the focus ring drawn around the button on keyboard focus. The Color parameter wins over it. |
| --bit-Button-radius | --bit-shp-radius-button | Corner radius of the box, which the focus ring follows. The Rounded parameter wins over it. |
| --bit-Button-border-width | --bit-shp-brd-width | Thickness of the border on every variant. |
| --bit-Button-shadow | none | Elevation of the box, for a design system whose buttons are raised rather than flat. A Float or FloatAbsolute button is lifted by --bit-Button-float-shadow instead. |
| --bit-Button-padding | --bit-siz-ctrl-pad-y-md --bit-siz-ctrl-pad-x-md | Padding of the box. An icon-only button takes its vertical padding on all four sides instead. The Size parameter wins over it. |
| --bit-Button-min-width | --bit-siz-ctrl-min-width | Smallest width of a labeled button, for lining up a row of buttons whose labels differ in length. FullWidth and NoWrap drop it to zero unless it is set, since both size the button by its container. |
| --bit-Button-min-height | --bit-siz-ctrl-md | Smallest height of the box, and the smallest width of an icon-only one. It is a floor, not a height: the box still grows with a wrapped label or a secondary line. The Size parameter wins over it. |
| --bit-Button-gap | spacing(1) | Room between the icon and the text, and between the loading spinner and its label. The Size parameter wins over it. |
| --bit-Button-font-size | --bit-tpg-fs-sm | Size of the primary text. The Size parameter wins over it. |
| --bit-Button-secondary-font-size | --bit-tpg-fs-xs | Size of the secondary text, one ramp step below the primary text by default. The Size parameter wins over it. |
| --bit-Button-secondary-color | The button's own foreground | Color of the secondary line of text. It is not muted by default, since on a filled button the contrast of the smaller of the two lines is what a muted color spends first. |
| --bit-Button-font-weight | --bit-tpg-font-weight | Weight of both lines of text. |
| --bit-Button-text-transform | --bit-tpg-ctrl-text-transform | Casing of both lines of text. Set it to none to drop the uppercasing of the buttons alone, without touching the other controls that share the global token. |
| --bit-Button-letter-spacing | --bit-tpg-ctrl-letter-spacing | Tracking of both lines of text, which usually moves with the casing above. |
| --bit-Button-icon-size | --bit-siz-icon-md | Size of the icon, for a glyph and an IconUrl image alike. The Size parameter wins over it. |
| --bit-Button-spinner-size | --bit-siz-icon-md | Diameter of the loading spinner, the icon's size by default. The Size parameter wins over it. |
| --bit-Button-spinner-color | The button's own foreground | The spinner's moving arc. Reading the foreground by default is what keeps it legible over the filled background of one variant and the transparent one of the others. |
| --bit-Button-spinner-track-color | The button's own foreground at 25% | The ring the arc travels on. |
| --bit-Button-float-offset | 1rem | Inset of a Float or FloatAbsolute button from the edge it is pinned to. The FloatOffset parameter writes this variable on the instance. |
| --bit-Button-float-shadow | --bit-shd-card | Elevation of a Float or FloatAbsolute button, which is what lifts it off the content it sits over. The focus ring is a shadow too and replaces it while the button is focused. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitButton parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AllowDisabledFocus | bool | true | Keeps the disabled button focusable and discoverable by screen readers, rendering aria-disabled instead of the native disabled attribute when Disabled is true, preserving a consistent tab order. Set it to false to render the native disabled attribute and remove the button from the tab order. |
| 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, not as part of it. An aria-describedby written on the component by hand is kept and this description is added to it, since the attribute is a list of ids. |
| AriaHidden | bool | false | If true, adds an aria-hidden attribute instructing screen readers to ignore the button. |
| AutoFocus | bool | false | If true, the 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. The state is left even when the handler throws. |
| ButtonType | BitButtonType? | null | The type of the button element; defaults to submit inside an EditForm otherwise button. |
| ChildContent | RenderFragment? | null | The content of primary section of the button. |
| Classes | BitButtonClassStyles? | null | Custom CSS classes for different parts of the button. |
| Color | BitColor? | null | The general color of the button. An explicit value wins over the --bit-Button-* color variables (the disabled and focus colors included); left unset, the button is primary unless they say otherwise. |
| Download | string? | null | The value of the download attribute of the link rendered by the button when Href is provided. Instructs the browser to download the linked resource instead of navigating to it, using the provided value as the file name. |
| Draggable | bool | false | Makes the Float/FloatAbsolute button draggable on the page, by pointer or with the arrow keys while it has the focus; ignored when neither is set. |
| FixedColor | bool | false | Preserves the foreground color of the button through hover and focus. |
| Float | bool | false | Enables floating behavior for the button, allowing it to be positioned relative to the viewport. |
| FloatAbsolute | bool | false | Enables floating behavior for the button, allowing it to be positioned relative to its container. |
| FloatOffset | string? | null | Specifies the offset of the floating button: any CSS length (1rem, 5%, a calc()), or a bare number, which is read as pixels. |
| FloatPosition | BitPosition? | null | Specifies the position of the floating button. |
| FormId | string? | null | The id of the form element that the 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 | Expand the button width to 100% of the available width. |
| 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 | Determines that only the icon should be rendered; the text is kept as screen-reader-only content, so the button keeps its accessible name unless an AriaLabel replaces it. |
| IconPlacement | BitPlacement? | null | Gets or sets the position of the icon relative to the component's content. The default value is Start. Only Start and End are honoured, and they follow the reading direction; any other value leaves the icon where Start would put it. |
| IconUrl | string? | null | The url of the custom icon to render inside the button. |
| IsLoading | bool | false | Determines whether the button is in loading mode or not. The spinner is stacked over the content rather than replacing it, so the box keeps its size and its accessible name, and the button reports aria-busy - plus aria-disabled unless Reclickable is set, since the click is refused. |
| LoadingDelay | int | 0 | The delay in milliseconds before the spinner appears after the button enters the loading state, so an operation that finishes inside the delay never flashes one. Only the visuals wait: the click is blocked and aria-busy is rendered as soon as the loading starts. |
| LoadingLabel | string? | null | The loading label text to show next to the spinner icon. It is also announced by assistive technologies from a live region beside the button, so that it is heard as a change of state instead of changing the name of the button itself. |
| LoadingLabelPlacement | BitPlacement | BitPlacement.End | The position of the loading Label in regards to the spinner icon. Only Top, Bottom, Start and End are honoured; any other value falls back to the default. |
| LoadingTemplate | RenderFragment? | null | The custom template used to replace the default spinner and loading label inside the button in the loading state. Like the spinner it replaces, it is hidden from assistive technologies; use LoadingLabel for what should be announced. |
| NoWrap | bool | false | Keeps each line of the button's text on a single line and ends it with an ellipsis where it does not fit. |
| OnClick | EventCallback<bool> | Raised when the button is clicked; receives a bool indicating the current loading state. | |
| PrimaryTemplate | RenderFragment? | The content of the primary section of the button (alias of the ChildContent). | |
| Reclickable | bool | false | Enables re-clicking while the button is in the loading state, which also keeps it reported and drawn as an available control instead of a busy and disabled one. |
| Rel | BitLinkRels? | null | Sets the rel attribute for link-rendered buttons when Href is a non-anchor URL; ignored for empty or hash-only hrefs. |
| Rounded | bool | false | Renders the button with fully rounded (pill shaped) corners, and an icon-only one as a circle. It wins over --bit-Button-radius, which restyles the default corner and not a rounded one. |
| SecondaryText | string? | null | The text of the secondary section of the button. |
| SecondaryTemplate | RenderFragment? | The custom template for the secondary section of the button. | |
| Size | BitSize? | null | Sets the preset size for typography and padding of the button. An explicit value wins over the --bit-Button-* size variables (padding, min-height, gap, font, icon and spinner sizes); left unset, the button is medium unless they say otherwise. |
| StopPropagation | bool | false | If true, stops the click event from bubbling up to the parent elements. |
| Styles | BitButtonClassStyles? | null | Custom inline styles for different parts of the button. |
| Target | string? | null | Specifies target attribute of the link when the 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 automatically for security. |
| Title | string? | null | The tooltip to show when the mouse is placed on the button. |
| Variant | BitVariant? | null | The visual variant of the button. |
BitButton public members
| Name | Type | Default value | Description |
|---|---|---|---|
| FocusAsync | ValueTask | Gives focus to the root element of the 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. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| 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. |
| 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. |
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. |
BitVariant enum
| Name | Value | Description |
|---|---|---|
| Fill | 0 | Fill styled variant. |
| Outline | 1 | Outline styled variant. |
| Text | 2 | Text styled variant. |
BitColor enum
| Name | Value | Description |
|---|---|---|
| Primary | 0 | 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. |
| Medium | 1 | The medium size. |
| Large | 2 | The large size. |
BitPlacement enum
| Name | Value | Description |
|---|---|---|
| Top | 0 | The top edge. |
| Bottom | 1 | The bottom edge. |
| Start | 2 | The edge the reading direction starts from - the left in LTR, the right in RTL. On the vertical axis, which does not turn around, it is the top. |
| End | 3 | The edge the reading direction ends at - the right in LTR, the left in RTL. On the vertical axis, which does not turn around, it is the bottom. |
| Left | 4 | The left edge, in both reading directions. |
| Right | 5 | The right edge, in both reading directions. |
| Center | 6 | The middle of the axis, against neither edge. |
| TopAndBottom | 7 | Both edges of the block axis at once. |
| StartAndEnd | 8 | Both edges of the inline axis at once, following the reading direction the way Start and End do. |
BitLinkRels enum
| Name | Value | Description |
|---|---|---|
| Alternate | 1 | Provides a link to an alternate representation of the document. (i.e. print page, translated or mirror) |
| Author | 2 | Provides a link to the author of the document. |
| Bookmark | 4 | Permanent URL used for bookmarking. |
| External | 8 | Indicates that the referenced document is not part of the same site as the current document. |
| Help | 16 | Provides a link to a help document. |
| License | 32 | Provides a link to licensing information for the document. |
| Next | 64 | Provides a link to the next document in the series. |
| NoFollow | 128 | Links to an unendorsed document, like a paid link. ("NoFollow" is used by Google, to specify that the Google search spider should not follow that link) |
| NoOpener | 256 | Requires that any browsing context created by following the hyperlink must not have an opener browsing context. |
| NoReferrer | 512 | Makes the referrer unknown. No referrer header will be included when the user clicks the hyperlink. |
| Prev | 1024 | The previous document in a selection. |
| Search | 2048 | Links to a search tool for the document. |
| Tag | 4096 | A tag (keyword) for the current document. |
| Me | 8192 | Indicates that the linked document represents the person who owns the current content. (used for identity verification) |
| Opener | 16384 | Requires that any browsing context created by following the hyperlink keeps its opener browsing context. (reverses the implicit noopener modern browsers apply to _blank targets) |
| PrivacyPolicy | 32768 | Links to the privacy policy that applies to the current document. (rendered as privacy-policy) |
| Sponsored | 65536 | Marks the link as an advertisement or paid placement, so search engines do not count it as an organic endorsement. |
| TermsOfService | 131072 | Links to the terms of service that apply to the current document. (rendered as terms-of-service) |
| Ugc | 262144 | Marks the link as user-generated content, like forum posts or comments, for search engines. |
BitPosition enum
| Name | Value | Description |
|---|---|---|
| TopLeft | 0 | The top left corner, in both reading directions. |
| TopCenter | 1 | The top edge, centered horizontally. |
| TopRight | 2 | The top right corner, in both reading directions. |
| TopStart | 3 | The top edge, on the side the reading direction starts from. |
| TopEnd | 4 | The top edge, on the side the reading direction ends at. |
| CenterLeft | 5 | The left edge, centered vertically, in both reading directions. |
| Center | 6 | Centered both ways. |
| CenterRight | 7 | The right edge, centered vertically, in both reading directions. |
| CenterStart | 8 | Centered vertically, on the side the reading direction starts from. |
| CenterEnd | 9 | Centered vertically, on the side the reading direction ends at. |
| BottomLeft | 10 | The bottom left corner, in both reading directions. |
| BottomCenter | 11 | The bottom edge, centered horizontally. |
| BottomRight | 12 | The bottom right corner, in both reading directions. |
| BottomStart | 13 | The bottom edge, on the side the reading direction starts from. |
| BottomEnd | 14 | The bottom edge, on the side the reading direction ends at. |
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.