ActionButton
ActionButton is a special type of button with a specific set of visual styles and properties.
Usage
Basic
<BitActionButton IconName="@BitIconName.AddFriend">Create account</BitActionButton>
<BitActionButton IconName="@BitIconName.AddFriend" ReversedIcon>Reversed Icon</BitActionButton>
<BitActionButton IconName="@BitIconName.AddFriend" IsEnabled="false">Disabled</BitActionButton>
<BitActionButton>No Icon</BitActionButton>Href
Use BitActionButton as a hyperlink to external URLs, opening either in a new tab or the same tab.
<BitActionButton IconName="@BitIconName.Globe" Href="https://bitplatform.dev" Target="_blank">
Open bitplatform.dev
</BitActionButton>
<BitActionButton IconName="@BitIconName.Globe" Href="https://github.com/bitfoundation/bitplatform">
Go to bitplatform GitHub
</BitActionButton>Rel
Use BitActionButton as a hyperlink to external URLs, with a rel attribute.
<BitActionButton Rel="BitLinkRel.NoFollow" Href="https://bitplatform.dev" Target="_blank" IconName="@BitIconName.Globe" Variant="BitVariant.Outline">
Open bitplatform.dev with a rel attribute (nofollow)
</BitActionButton>
<BitActionButton Rel="BitLinkRel.NoFollow | BitLinkRel.NoReferrer" Href="https://bitplatform.dev" Target="_blank" IconName="@BitIconName.Globe" Variant="BitVariant.Outline">
Open bitplatform.dev with a rel attribute (nofollow & noreferrer)
</BitActionButton>Color
Demonstrates BitActionButton with various predefined colors: Primary, Secondary, Tertiary, Info, Success, Warning, SevereWarning, and Error.
<BitActionButton Color="BitColor.Primary" IconName="@BitIconName.ColorSolid">Primary</BitActionButton>
<BitActionButton Color="BitColor.Primary">Primary</BitActionButton>
<BitActionButton Color="BitColor.Secondary" IconName="@BitIconName.ColorSolid">Secondary</BitActionButton>
<BitActionButton Color="BitColor.Secondary">Secondary</BitActionButton>
<BitActionButton Color="BitColor.Tertiary" IconName="@BitIconName.ColorSolid">Tertiary</BitActionButton>
<BitActionButton Color="BitColor.Tertiary">Tertiary</BitActionButton>
<BitActionButton Color="BitColor.Info" IconName="@BitIconName.ColorSolid">Info</BitActionButton>
<BitActionButton Color="BitColor.Info">Info</BitActionButton>
<BitActionButton Color="BitColor.Success" IconName="@BitIconName.ColorSolid">Success</BitActionButton>
<BitActionButton Color="BitColor.Success">Success</BitActionButton>
<BitActionButton Color="BitColor.Warning" IconName="@BitIconName.ColorSolid">Warning</BitActionButton>
<BitActionButton Color="BitColor.Warning">Warning</BitActionButton>
<BitActionButton Color="BitColor.SevereWarning" IconName="@BitIconName.ColorSolid">SevereWarning</BitActionButton>
<BitActionButton Color="BitColor.SevereWarning">SevereWarning</BitActionButton>
<BitActionButton Color="BitColor.Error" IconName="@BitIconName.ColorSolid">Error</BitActionButton>
<BitActionButton Color="BitColor.Error">Error</BitActionButton>
<BitActionButton Color="BitColor.PrimaryBackground" IconName="@BitIconName.ColorSolid">PrimaryBackground</BitActionButton>
<BitActionButton Color="BitColor.PrimaryBackground">PrimaryBackground</BitActionButton>
<BitActionButton Color="BitColor.SecondaryBackground" IconName="@BitIconName.ColorSolid">SecondaryBackground</BitActionButton>
<BitActionButton Color="BitColor.SecondaryBackground">SecondaryBackground</BitActionButton>
<BitActionButton Color="BitColor.TertiaryBackground" IconName="@BitIconName.ColorSolid">TertiaryBackground</BitActionButton>
<BitActionButton Color="BitColor.TertiaryBackground">TertiaryBackground</BitActionButton>
<BitActionButton Color="BitColor.PrimaryForeground" IconName="@BitIconName.ColorSolid">PrimaryForeground</BitActionButton>
<BitActionButton Color="BitColor.PrimaryForeground">PrimaryForeground</BitActionButton>
<BitActionButton Color="BitColor.SecondaryForeground" IconName="@BitIconName.ColorSolid">SecondaryForeground</BitActionButton>
<BitActionButton Color="BitColor.SecondaryForeground">SecondaryForeground</BitActionButton>
<BitActionButton Color="BitColor.TertiaryForeground" IconName="@BitIconName.ColorSolid">TertiaryForeground</BitActionButton>
<BitActionButton Color="BitColor.TertiaryForeground">TertiaryForeground</BitActionButton>
<BitActionButton Color="BitColor.PrimaryBorder" IconName="@BitIconName.ColorSolid">PrimaryBorder</BitActionButton>
<BitActionButton Color="BitColor.PrimaryBorder">PrimaryBorder</BitActionButton>
<BitActionButton Color="BitColor.SecondaryBorder" IconName="@BitIconName.ColorSolid">SecondaryBorder</BitActionButton>
<BitActionButton Color="BitColor.SecondaryBorder">SecondaryBorder</BitActionButton>
<BitActionButton Color="BitColor.TertiaryBorder" IconName="@BitIconName.ColorSolid">TertiaryBorder</BitActionButton>
<BitActionButton Color="BitColor.TertiaryBorder">TertiaryBorder</BitActionButton>Size
Show BitActionButton in different sizes: Small, Medium, and Large.
<BitActionButton Size="BitSize.Small" IconName="@BitIconName.FontSize">Small</BitActionButton>
<BitActionButton Size="BitSize.Medium" IconName="@BitIconName.FontSize">Medium</BitActionButton>
<BitActionButton Size="BitSize.Large" IconName="@BitIconName.FontSize">Large</BitActionButton>Style & Class
Customize the appearance of BitActionButton using styles and CSS classes.
<style>
.custom-icon {
color: hotpink;
}
.custom-content {
position: relative;
}
.custom-content::after {
content: '';
left: 0;
width: 0;
height: 2px;
bottom: -6px;
position: absolute;
transition: 0.3s ease;
background: linear-gradient(90deg, #ff00cc, #3333ff);
}
.custom-root:hover .custom-content {
color: blueviolet;
}
.custom-root:hover .custom-content::after {
width: 100%;
}
</style>
<BitActionButton IconName="@BitIconName.Brush"
Styles="@(new() { Root = "font-size: 1.5rem;",
Icon = "color: blueviolet;",
Content = "text-shadow: aqua 0 0 1rem;" })">
Action Button Styles
</BitActionButton>
<BitActionButton IconName="@BitIconName.FormatPainter"
Classes="@(new() { Root = "custom-root",
Icon = "custom-icon",
Content = "custom-content" })">
Action Button Classes (Hover me)
</BitActionButton>Template
Add custom template within BitActionButton.
<BitActionButton IconName="@BitIconName.AddFriend">
<div style="display:flex;gap:0.5rem;">
<div>This is a custom template</div>
<BitSpinnerLoading CustomSize="20" />
</div>
</BitActionButton>Button Type
Use BitActionButton within a form and validate its state.
<EditForm Model="validationButtonModel" OnValidSubmit="HandleValidSubmit"> <DataAnnotationsValidator /> <ValidationSummary /> <BitTextField Label="Required" Required @bind-Value="validationButtonModel.RequiredText" /> <ValidationMessage For="() => validationButtonModel.RequiredText" style="color:red" /> <BitTextField Label="Nonrequired" @bind-Value="validationButtonModel.NonRequiredText" /> <div> <BitActionButton IconName="@BitIconName.SendMirrored" ButtonType="BitButtonType.Submit">Submit</BitActionButton> <BitActionButton IconName="@BitIconName.Reset" ButtonType="BitButtonType.Reset">Reset</BitActionButton> <BitActionButton IconName="@BitIconName.ButtonControl" ButtonType="BitButtonType.Button">Button</BitActionButton> </div> </EditForm>@code { public class ButtonValidationModel { [Required] public string RequiredText { get; set; } = string.Empty; public string? NonRequiredText { get; set; } } private ButtonValidationModel validationButtonModel = new(); private async Task HandleValidSubmit() { await Task.Delay(2000); validationButtonModel = new(); StateHasChanged(); } }
RTL
Use BitActionButton in right-to-left (RTL).
<BitActionButton Dir="BitDir.Rtl" IconName="@BitIconName.AddFriend">ساخت حساب</BitActionButton>API
BitActionButton parameters
Name |
Type |
Default value |
Description |
|---|---|---|---|
| AllowDisabledFocus | bool | false | Whether the button can have focus in disabled mode. |
| AriaDescription | string? | null | Detailed description of the button for the benefit of screen readers. |
| AriaHidden | bool | false | If true, add an aria-hidden attribute instructing screen readers to ignore the button. |
| ButtonType | BitButtonType | null | The type html attribute of the button element. |
| ChildContent | RenderFragment? | null | The content of the button. |
| Classes | BitActionButtonClassStyles? | null | Custom CSS classes for different parts of the button. |
| Color | BitColor? | null | The general color of the button. |
| FullWidth | bool | false | Renders the action button in full width of its container with flex-start. |
| 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. |
| IconName | string? | null | The icon name of the icon to render inside the button. |
| IconOnly | bool | null | Removes the container of the text and only renders the icon. |
| OnClick | EventCallback<MouseEventArgs> | The callback for the click event of the button. | |
| Styles | BitActionButtonClassStyles? | null | Custom CSS styles for different parts of the button. |
| ReversedIcon | bool | false | Reverses the positions of the icon and the content of the button. |
| Rel | BitLinkRel? | null | If Href provided, specifies the relationship between the current document and the linked document. |
| Size | BitSize? | null | The size of the button. |
| Target | string? | null | Specifies target attribute of the link when the button renders as an anchor (by providing the Href parameter). |
| Title | string? | null | The tooltip to show when the mouse is placed on the button. |
BitComponentBase parameters
Name |
Type |
Default value |
Description |
|---|---|---|---|
| AriaLabel | string? | null | The aria-label of the control for the benefit of screen readers. |
| Class | string? | null | Custom CSS class for the root element of the component. |
| Dir | BitDir? | null | Determines the component direction. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Capture and render additional attributes in addition to the component's parameters. |
| Id | string? | null | Custom id attribute for the root element. if null the UniqueId will be used instead. |
| IsEnabled | bool | true | Whether or not the component is enabled. |
| Style | string? | null | Custom CSS style for the root element of the component. |
| Visibility | BitVisibility | BitVisibility.Visible | Whether the component is visible, hidden or collapsed. |
BitComponentBase public members
Name |
Type |
Default value |
Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | The readonly unique id of the root element. it will be assigned to a new Guid at component instance construction. |
| RootElement | ElementReference | The ElementReference of the root element. |
BitActionButtonClassStyles properties
Name |
Type |
Default value |
Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitActionButton. |
| Icon | string? | null | Custom CSS classes/styles for the Icon of the BitActionButton. |
| Content | string? | null | Custom CSS classes/styles for the content of the BitActionButton. |
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. |
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
You can give us your feedback through our GitHub repo by filing a new Issue or starting a new Discussion.
Or you can review / edit this page on GitHub.
Or you can review / edit this component on GitHub.
- On this page