Button

As defined by the W3C:

A button is a widget that enables users to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.

<FluentButton> wraps the <fluent-button> element, a web component implementation of an HTML button element leveraging the Fluent UI design system. The <FluentButton> component supports several visual appearances (accent, lightweight, neutral, outline, stealth).

Examples

Simple button examples

Although it is possible to use Appearance.Hypertext on a button, this still renders a button due to a change in the underlying web component. We will remove this specific appearance value in a future version.
Example
Button Accent Lightweight Outline Stealth Colored Loading
Download: 

With content and icon

Example

With icon at Start or End

Button Button Button Button

With icon in default slot

With icon in the content. By doing it this way, it is possible to specify a Color for the icon.

Button

With icon and loading

Refresh Refresh
Download: 

With aria-label

Example

With aria-label

Button

Autofocus

Commented out to prevent page actually jumping to this location. See Razor tab for implementation.

Download: 

Documentation

FluentButton Class

Parameters

Name
Type
Default
Description
Actionstring?
See button element for more details.
AppearanceAppearance?
Neutral
Gets or sets the visual appearance. See Appearance
Defaults to Appearance.Neutral
Autofocusbool?
Determines if the element should receive document focus on page load.
BackgroundColorstring?
Gets or sets the background color of this button (overrides the FluentButton.Appearance property).
Set the value 'rgba(0, 0, 0, 0)' to display a transparent button.
ChildContentRenderFragment?
Gets or sets the content to be rendered inside the component.
Colorstring?
Gets or sets the color of the font (overrides the FluentButton.Appearance property).
CurrentValuestring?
Gets or sets the element's current value.
Disabledbool
False
Disables the form control, ensuring it doesn't participate in form submission.
Enctypestring?
See button element for more details.
FormIdstring?
Gets or sets the id of a form to associate the element to.
Both the FluentComponentBase.Id and the FormId must be set if the button is placed outside of a form.
IconEndIcon?
Gets or sets the Icon displayed at the end of button content.
IconStartIcon?
Gets or sets the Icon displayed at the start of button content.
Loadingbool
False
Display a progress ring and disable the button.
Methodstring?
See button element for more details.
Namestring?
Gets or sets the name of the element.
Allows access by name from the associated form.
NoValidatebool?
See button element for more details.
Requiredbool
False
Gets or sets a value indicating whether the element needs to have a value.
StopPropagationbool
False
Gets or sets a way to prevent further propagation of the current event in the capturing and bubbling phases.
Targetstring?
See button element for more details.
Possible values: '_self' | '_blank' | '_parent' | '_top'
Titlestring?
Gets or sets the title of the button.
The text usually displayed in a 'tooltip' popup when the mouse is over the button.
TypeButtonType?
Button
Gets or sets the button type. See ButtonType for more details.
Default is ButtonType.Button.
Valuestring?
Gets or sets the value of the element.

EventCallbacks

Name
Type
Description
OnClickEventCallback<MouseEventArgs>
Command executed when the user clicks on the button.

Methods

Name
Parameters
Type
Description
DisposeAsyncValueTask
SetDisabledbool disabled
void
Neutral
Accent
Hypertext
Lightweight
Outline
Stealth
Filled
Button
Submit
Reset
An error has occurred. This application may no longer respond until reloaded. Reload 🗙