Button
Use the Button component to style actions in forms, dialogs, and more, with support for multiple sizes, states, and other options.
How it works #
The Button component provides styled buttons for various actions such as navigation, form submission, and resetting forms.
How to use:
This demo shows how to create different types of buttons for common UI actions.
How to use:
- Add the
Buttoncomponent to your page. - Set the
Typeproperty toButtonType.Link,ButtonType.Submit, orButtonType.Resetas needed. - Customize the button label by setting the content between the opening and closing
<Button>tags.
<Button Type="ButtonType.Link">Anchor</Button>
<Button>Button</Button>
<Button Type="ButtonType.Submit">Submit</Button>
<Button Type="ButtonType.Reset">Reset</Button>
Colors #
The Button component supports a variety of color options to match your application's theme or to indicate different actions.
How to use:
This demo displays the basic color options for the button component.
How to use:
- Set the
Colorproperty to one of the available color values such asButtonColor.White,ButtonColor.Light,ButtonColor.Dark,ButtonColor.Black,ButtonColor.Text, orButtonColor.Ghost. - Place your button label between the
<Button>tags.
<Button Color="ButtonColor.White">White</Button>
<Button Color="ButtonColor.Light">Light</Button>
<Button Color="ButtonColor.Dark">Dark</Button>
<Button Color="ButtonColor.Black">Black</Button>
<Button Color="ButtonColor.Text">Text</Button>
<Button Color="ButtonColor.Ghost">Ghost</Button>
Use semantic color options to indicate the purpose of each button, such as primary actions, links, information, success, warnings, or danger.
How to use:
This demo shows how to apply semantic colors to buttons for better user guidance.
How to use:
- Set the
Colorproperty toButtonColor.Primary,ButtonColor.Link,ButtonColor.Info,ButtonColor.Success,ButtonColor.Warning, orButtonColor.Danger.
<Button Color="ButtonColor.Primary">Primary</Button>
<Button Color="ButtonColor.Link">Link</Button>
<Button Color="ButtonColor.Info">Info</Button>
<Button Color="ButtonColor.Success">Success</Button>
<Button Color="ButtonColor.Warning">Warning</Button>
<Button Color="ButtonColor.Danger">Danger</Button>
The IsLightVersion property provides a lighter variant of the button color, useful for subtle emphasis or lighter backgrounds.
How to use:
This demo demonstrates the light color variants for each button.
How to use:
- Set the
IsLightVersionproperty totrueon yourButtoncomponent. - Combine with the
Colorproperty for the desired color.
<Button Color="ButtonColor.Primary" IsLightVersion="true">Primary</Button>
<Button Color="ButtonColor.Link" IsLightVersion="true">Link</Button>
<Button Color="ButtonColor.Info" IsLightVersion="true">Info</Button>
<Button Color="ButtonColor.Success" IsLightVersion="true">Success</Button>
<Button Color="ButtonColor.Warning" IsLightVersion="true">Warning</Button>
<Button Color="ButtonColor.Danger" IsLightVersion="true">Danger</Button>
The IsDarkVersion property provides a darker variant of the button color, ideal for dark themes or strong emphasis.
How to use:
This demo shows the dark color variants for each button.
How to use:
- Set the
IsDarkVersionproperty totrueon yourButtoncomponent. - Combine with the
Colorproperty for the desired color.
<Button Color="ButtonColor.Primary" IsDarkVersion="true">Primary</Button>
<Button Color="ButtonColor.Link" IsDarkVersion="true">Link</Button>
<Button Color="ButtonColor.Info" IsDarkVersion="true">Info</Button>
<Button Color="ButtonColor.Success" IsDarkVersion="true">Success</Button>
<Button Color="ButtonColor.Warning" IsDarkVersion="true">Warning</Button>
<Button Color="ButtonColor.Danger" IsDarkVersion="true">Danger</Button>
Sizes #
The Button component supports multiple sizes to fit different UI needs, from small to large.
How to use:
This demo shows how to use different button sizes.
How to use:
- Set the
Sizeproperty toButtonSize.Small,ButtonSize.Normal,ButtonSize.Medium, orButtonSize.Largeas needed.
<Buttons>
<Button Size="ButtonSize.Small">Small</Button>
<Button>Default</Button>
<Button Size="ButtonSize.Normal">Normal</Button>
<Button Size=" ButtonSize.Medium">Medium</Button>
<Button Size=" ButtonSize.Large">Large</Button>
</Buttons>
You can set the size for a group of buttons by applying the
How to use:
This demo shows a group of small buttons.
Size property to the Buttons container.
How to use:
- Wrap your
Buttoncomponents in aButtonscontainer. - Set the
Sizeproperty on theButtonscontainer to apply the size to all child buttons.
<Buttons Size="ButtonSize.Small">
<Button Color="ButtonColor.Primary">Primary</Button>
<Button Color="ButtonColor.Link">Link</Button>
<Button Color="ButtonColor.Info">Info</Button>
<Button Color="ButtonColor.Success">Success</Button>
<Button Color="ButtonColor.Warning">Warning</Button>
<Button Color="ButtonColor.Danger">Danger</Button>
</Buttons>
This demo demonstrates a group of medium-sized buttons using the
How to use:
Size property on the Buttons container.
How to use:
- Wrap your
Buttoncomponents in aButtonscontainer. - Set
Size="ButtonSize.Medium"on theButtonscontainer.
<Buttons Size="ButtonSize.Medium">
<Button Color="ButtonColor.Primary">Primary</Button>
<Button Color="ButtonColor.Link">Link</Button>
<Button Color="ButtonColor.Info">Info</Button>
<Button Color="ButtonColor.Success">Success</Button>
<Button Color="ButtonColor.Warning">Warning</Button>
<Button Color="ButtonColor.Danger">Danger</Button>
</Buttons>
This demo demonstrates a group of large buttons using the
How to use:
Size property on the Buttons container.
How to use:
- Wrap your
Buttoncomponents in aButtonscontainer. - Set
Size="ButtonSize.Large"on theButtonscontainer.
<Buttons Size="ButtonSize.Large">
<Button Color="ButtonColor.Primary">Primary</Button>
<Button Color="ButtonColor.Link">Link</Button>
<Button Color="ButtonColor.Info">Info</Button>
<Button Color="ButtonColor.Success">Success</Button>
<Button Color="ButtonColor.Warning">Warning</Button>
<Button Color="ButtonColor.Danger">Danger</Button>
</Buttons>
You can override the group size for individual buttons by setting the
How to use:
This demo shows a group of large buttons with one button using a custom size.
Size property on a specific Button inside a Buttons container.
How to use:
- Set the
Sizeproperty on theButtonscontainer for a default group size. - Override the size for any
Buttonby setting its ownSizeproperty.
<Buttons Size="ButtonSize.Large">
<Button Color="ButtonColor.Primary">Primary</Button>
<Button Color="ButtonColor.Link">Link</Button>
<Button Color="ButtonColor.Info">Info</Button>
<Button Color="ButtonColor.Success">Success</Button>
<Button Color="ButtonColor.Warning" Size="ButtonSize.Normal">Warning</Button>
<Button Color="ButtonColor.Danger">Danger</Button>
</Buttons>Full width #
The IsFullWidth property makes a button expand to fill the width of its container, useful for responsive layouts or call-to-action buttons.
How to use:
This demo shows buttons of various sizes set to full width.
How to use:
- Set the
IsFullWidthproperty totrueon yourButtoncomponent. - Optionally, set the
Sizeproperty for different button heights.
<Buttons>
<Button Size="ButtonSize.Small" IsFullWidth="true">Small</Button>
<Button IsFullWidth="true">Default</Button>
<Button Size="ButtonSize.Normal" IsFullWidth="true">Normal</Button>
<Button Size=" ButtonSize.Medium" IsFullWidth="true">Medium</Button>
<Button Size=" ButtonSize.Large" IsFullWidth="true">Large</Button>
</Buttons>Responsive sizes #
The IsResponsive property allows buttons to automatically adjust their size based on the screen size, improving usability on different devices.
How to use:
This demo compares fixed-size and responsive-size buttons in a table layout.
How to use:
- Set the
IsResponsiveproperty totrueon yourButtoncomponent. - Combine with the
Sizeproperty for more control over the default size.
| Name | Fixed size | Responsive size |
| Default | ||
| Small | ||
| Normal | ||
| Medium | ||
| Large |
<div class="table-container">
<table class="table is-bordered">
<thead>
<tr>
<td>Name</td>
<td>Fixed size</td>
<td>Responsive size</td>
</tr>
</thead>
<tbody>
<tr>
<td>Default</td>
<td><Button>Default</Button></td>
<td><Button IsResponsive="true">Default</Button></td>
</tr>
<tr>
<td>Small</td>
<td><Button Size="ButtonSize.Small">Small</Button></td>
<td><Button Size="ButtonSize.Small" IsResponsive="true">Small</Button></td>
</tr>
<tr>
<td>Normal</td>
<td><Button Size="ButtonSize.Normal">Normal</Button></td>
<td><Button Size="ButtonSize.Normal" IsResponsive="true">Normal</Button></td>
</tr>
<tr>
<td>Medium</td>
<td><Button Size="ButtonSize.Medium">Medium</Button></td>
<td><Button Size="ButtonSize.Medium" IsResponsive="true">Medium</Button></td>
</tr>
<tr>
<td>Large</td>
<td><Button Size="ButtonSize.Large">Large</Button></td>
<td><Button Size="ButtonSize.Large" IsResponsive="true">Large</Button></td>
</tr>
</tbody>
</table>
</div>Styles #
The IsOutlined property gives buttons an outlined style, making them less prominent while still interactive.
How to use:
This demo shows outlined buttons in various colors.
How to use:
- Set the
IsOutlinedproperty totrueon yourButtoncomponent. - Combine with the
Colorproperty for different outlined color styles.
<Button Color="ButtonColor.Primary" IsOutlined="true">Primary</Button>
<Button Color="ButtonColor.Link" IsOutlined="true">Link</Button>
<Button Color="ButtonColor.Info" IsOutlined="true">Info</Button>
<Button Color="ButtonColor.Success" IsOutlined="true">Success</Button>
<Button Color="ButtonColor.Warning" IsOutlined="true">Warning</Button>
<Button Color="ButtonColor.Danger" IsOutlined="true">Danger</Button>
The IsInverted property inverts the button's color scheme, making it suitable for use on colored backgrounds.
How to use:
This demo shows inverted buttons in various colors.
How to use:
- Set the
IsInvertedproperty totrueon yourButtoncomponent. - Combine with the
Colorproperty for different inverted color styles.
<Button Color="ButtonColor.Primary" IsInverted="true">Primary</Button>
<Button Color="ButtonColor.Link" IsInverted="true">Link</Button>
<Button Color="ButtonColor.Info" IsInverted="true">Info</Button>
<Button Color="ButtonColor.Success" IsInverted="true">Success</Button>
<Button Color="ButtonColor.Warning" IsInverted="true">Warning</Button>
<Button Color="ButtonColor.Danger" IsInverted="true">Danger</Button>
The IsRounded property gives buttons fully rounded corners for a pill-shaped appearance.
How to use:
This demo shows rounded buttons in various colors.
How to use:
- Set the
IsRoundedproperty totrueon yourButtoncomponent. - Combine with the
Colorproperty for different rounded color styles.
<Button Color="ButtonColor.Primary" IsRounded="true">Primary</Button>
<Button Color="ButtonColor.Link" IsRounded="true">Link</Button>
<Button Color="ButtonColor.Info" IsRounded="true">Info</Button>
<Button Color="ButtonColor.Success" IsRounded="true">Success</Button>
<Button Color="ButtonColor.Warning" IsRounded="true">Warning</Button>
<Button Color="ButtonColor.Danger" IsRounded="true">Danger</Button>
Loading #
The IsLoading property displays a loading spinner inside the button, indicating that an action is in progress.
How to use:
This demo shows loading buttons in various colors.
How to use:
- Set the
IsLoadingproperty totrueon yourButtoncomponent when an operation is running. - Optionally, combine with the
Colorproperty for different loading button styles.
<Buttons>
<Button IsLoading="true">Primary</Button>
<Button Color="ButtonColor.Primary" IsLoading="true">Primary</Button>
<Button Color="ButtonColor.Link" IsLoading="true">Link</Button>
<Button Color="ButtonColor.Info" IsLoading="true">Info</Button>
<Button Color="ButtonColor.Success" IsLoading="true">Success</Button>
<Button Color="ButtonColor.Warning" IsLoading="true">Warning</Button>
<Button Color="ButtonColor.Danger" IsLoading="true">Danger</Button>
</Buttons>Disabled #
The IsDisabled property disables the button, preventing user interaction and visually indicating its inactive state.
How to use:
This demo shows disabled buttons in various styles and colors.
How to use:
- Set the
IsDisabledproperty totrueon yourButtoncomponent. - Combine with the
ColororTypeproperty as needed.
<Buttons>
<Button Type="ButtonType.Link" IsDisabled="true">Anchor</Button>
<Button IsDisabled="true">Default</Button>
<Button Color="ButtonColor.Primary" IsDisabled="true">Primary</Button>
<Button Color="ButtonColor.Link" IsDisabled="true">Link</Button>
<Button Color="ButtonColor.Info" IsDisabled="true">Info</Button>
<Button Color="ButtonColor.Success" IsDisabled="true">Success</Button>
<Button Color="ButtonColor.Warning" IsDisabled="true">Warning</Button>
<Button Color="ButtonColor.Danger" IsDisabled="true">Danger</Button>
</Buttons>Click events #
The Button component supports click and double-click events, allowing you to handle user interactions with custom logic.
How to use:
This demo shows handling single click, double click, and click events with custom arguments.
How to use:
- Attach an
@onclickor@ondblclickevent handler to yourButtoncomponent. - Define the corresponding event handler method in your
@codeblock. - You can also pass additional arguments to your event handler as needed.
<Buttons>
<Button Color="ButtonColor.Primary" @onclick="OnClick">Click here</Button>
<Button Color="ButtonColor.Link" @ondblclick="OnDoubleClick">Double click here</Button>
<Button Color="ButtonColor.Info" @onclick="((args) => OnClickWithArgs(args, message))">Click event with args</Button>
</Buttons>
@code {
public string message = "Test message";
protected void OnClick(EventArgs args)
{
// handle click event
}
protected void OnDoubleClick(EventArgs args)
{
// handle double click event
}
protected void OnClickWithArgs(EventArgs args, string message)
{
// handle click event with custom params
}
}