HxButton

Button (<button type="button">). See also Bootstrap Buttons.

Demo #

<HxButton Text="Basic Button" Color="ThemeColor.Primary" />

Several predefined button styles are included, each serving its own semantic purpose, with a few extras thrown in for more control.

Outline buttons #

You can remove the background with Outline="true":

Sizes #

<HxButton Text="Large" Size="ButtonSize.Large" Color="ThemeColor.Primary" />
<HxButton Text="Large" Size="ButtonSize.Large" Color="ThemeColor.Primary" />
<HxButton Text="Small" Size="ButtonSize.Small" Color="ThemeColor.Primary" />
<HxButton Text="Small" Size="ButtonSize.Small" Color="ThemeColor.Primary" />

Icons #

You can add an icon to the button by using the Icon parameter. The position of the icon can be changed with IconPlacement.

Spinners #

Button will show a spinner whenever the OnClick handler returns an incomplete awaitable Task.

<HxButton Text="Button with a Spinner" Size="ButtonSize.Regular" Color="ThemeColor.Primary" OnClick="async () => await Task.Delay(2000)" />

OnValidClick with spinner

Manual Spinner

Spinner & Single click protection

Button with a badge #

<HxButton Color="ThemeColor.Primary">
    Send all <span class="badge bg-secondary">15</span>
</HxButton>

Button with a tooltip #

You can use Tooltip parameter to set button's tooltip:

<HxButton Text="Button with a tooltip" Icon="BootstrapIcon.ClockHistory" Tooltip="This is a tooltip with  very very long text. Is this tooltip text length enought? No. So let's make it even longer. And is the tooltip text long enought now? OK..." Color="ThemeColor.Secondary" />

Tooltip, wrapper and CSS classes

<div class="d-flex">
	<HxButton Text="Button with a tooltip"
			  Icon="BootstrapIcon.ClockHistory"
			  Color="ThemeColor.Secondary"
			  Tooltip="This is a tooltip with .text-uppercase."
			  TooltipCssClass="text-uppercase"
			  TooltipWrapperCssClass="ms-auto" />
</div>

API

Parameters

Name Type Description
AdditionalAttributes Dictionary<string, object> Additional attributes to be splatted onto an underlying <button> element.
ChildContent RenderFragment Button content.
Color ThemeColor? Bootstrap button style - theme color.
Default is taken from HxButton.Defaults (ThemeColor.None if not customized).
CssClass string Custom CSS class to render with the <button />.
When using Tooltip you might want to use TooltipWrapperCssClass instead of CssClass to get the desired result.
EditContext EditContext Associated EditContext.
Enabled bool? When null (default), the Enabled value is received from cascading FormState. When value is false, input is rendered as disabled. To set multiple controls as disabled use HxFormState.
FormId string Specifies the form the button belongs to.
Icon IconBase Icon to render into the button.
IconPlacement ButtonIconPlacement? Position of the icon within the button. Default is ButtonIconPlacement.Start (configurable through HxButton.Defaults).
OnClick EventCallback<MouseEventArgs> Raised after the button is clicked.
OnClickPreventDefault bool Prevents the default action for the onclick event. Deafult is false.
OnClickStopPropagation bool Stop onClick-event propagation. Deafult is true.
OnInvalidClick EventCallback<MouseEventArgs> Raised after the button is clicked and EditContext validation fails.
OnValidClick EventCallback<MouseEventArgs> Raised after the button is clicked and EditContext validation succeeds.
Outline bool? Bootstrap "outline" button style.
Settings ButtonSettings Set of settings to be applied to the component instance (overrides HxButton.Defaults, overriden by individual parameters).
SingleClickProtection bool Set false if you want to allow multiple OnClick handlers in parallel. Default is true.
Size ButtonSize? Button size. Default is ButtonSize.Regular.
Spinner bool? Set state of the embedded HxSpinner. Leave null if you want automated spinner when any of the OnClick handlers is running. You can set an explicit false constant to disable (override) the spinner automation.
Text string Text of the button.
Tooltip string Tooltip text.
If set, a span wrapper will be rendered around the <button />. For most scenarios you will then use TooltipWrapperCssClass instead of CssClass.
TooltipCssClass string Custom CSS class to render with the tooltip.
TooltipPlacement TooltipPlacement Tooltip placement.
TooltipWrapperCssClass string Custom CSS class to render with the tooltip span wrapper of the <button />.
If set, the span wrapper will be rendered no matter the Tooltip text is set or not.

Static properties

Property Type Description
Defaults ButtonSettings Application-wide defaults for HxButton and derived components.

HxSubmit

Button <button type="submit">. Direct ancestor of HxButton with the same API.

API

Parameters

Name Type Description
AdditionalAttributes Dictionary<string, object> Additional attributes to be splatted onto an underlying <button> element.
ChildContent RenderFragment Button content.
Color ThemeColor? Bootstrap button style - theme color.
Default is taken from HxButton.Defaults (ThemeColor.None if not customized).
CssClass string Custom CSS class to render with the <button />.
When using Tooltip you might want to use TooltipWrapperCssClass instead of CssClass to get the desired result.
EditContext EditContext Associated EditContext.
Enabled bool? When null (default), the Enabled value is received from cascading FormState. When value is false, input is rendered as disabled. To set multiple controls as disabled use HxFormState.
FormId string Specifies the form the button belongs to.
Icon IconBase Icon to render into the button.
IconPlacement ButtonIconPlacement? Position of the icon within the button. Default is ButtonIconPlacement.Start (configurable through HxButton.Defaults).
OnClick EventCallback<MouseEventArgs> Raised after the button is clicked.
OnClickPreventDefault bool Prevents the default action for the onclick event. Deafult is false.
OnClickStopPropagation bool Stop onClick-event propagation. Deafult is true.
OnInvalidClick EventCallback<MouseEventArgs> Raised after the button is clicked and EditContext validation fails.
OnValidClick EventCallback<MouseEventArgs> Raised after the button is clicked and EditContext validation succeeds.
Outline bool? Bootstrap "outline" button style.
Settings ButtonSettings Set of settings to be applied to the component instance (overrides HxButton.Defaults, overriden by individual parameters).
SingleClickProtection bool Set false if you want to allow multiple OnClick handlers in parallel. Default is true.
Size ButtonSize? Button size. Default is ButtonSize.Regular.
Spinner bool? Set state of the embedded HxSpinner. Leave null if you want automated spinner when any of the OnClick handlers is running. You can set an explicit false constant to disable (override) the spinner automation.
Text string Text of the button.
Tooltip string Tooltip text.
If set, a span wrapper will be rendered around the <button />. For most scenarios you will then use TooltipWrapperCssClass instead of CssClass.
TooltipCssClass string Custom CSS class to render with the tooltip.
TooltipPlacement TooltipPlacement Tooltip placement.
TooltipWrapperCssClass string Custom CSS class to render with the tooltip span wrapper of the <button />.
If set, the span wrapper will be rendered no matter the Tooltip text is set or not.

Static properties

Property Type Description
Defaults ButtonSettings Application-wide defaults for HxButton and derived components.
An unhandled error has occurred. Reload 🗙