Forms
TwCheckbox
TwCheckbox is a Blazor checkbox component. Bind Value or SelectedValues, set Color, Size, Disabled and Horizontal, or generate a group from Items.
Last updated
Basic Usage
Group checkboxes with
TwCheckboxGroup and bind individual values with @bind-Value.Sizes
Use
Size to render a smaller or larger checkbox. Defaults to Size.Md, the original size.Razor
<div class="flex items-center gap-6">
<TwCheckbox Label="Small" Value="true" Size="Size.Sm" Color="Color.Primary" />
<TwCheckbox Label="Medium" Value="true" Size="Size.Md" Color="Color.Primary" />
<TwCheckbox Label="Large" Value="true" Size="Size.Lg" Color="Color.Primary" />
</div>Indeterminate State
Bind a
TwCheckbox<bool?> and pass null to render it indeterminate - useful for a "select all" checkbox that reflects a partially-selected list below it. Clicking an indeterminate checkbox always resolves it to fully checked or unchecked; there's no click gesture that produces the indeterminate state itself.Colors
Group checkboxes with
TwCheckboxGroup and bind individual values with @bind-Value.Data-Driven (Automatic)
Use
Items and @bind-SelectedValues to generate checkboxes from a list.Selected: CSharp, JavaScript
Enabled notifications:
- Push
Horizontal Layout & Custom Spacing
Use
Horizontal to arrange checkboxes side-by-side, or Spacing="4" for custom spacing.Disabled State
Disable the entire group with the
Disabled property.Razor
<TwCheckboxGroup TValue="string" Legend="Premium features (Disabled)" Name="premium" Disabled>
<TwCheckbox Label="Advanced Analytics" Value="false" Color="Color.Accent" />
<TwCheckbox Label="Priority Support" Value="false" Color="Color.Accent" />
<TwCheckbox Label="Custom Branding" Value="false" Color="Color.Accent" />
</TwCheckboxGroup>Programmatic Control
Change selections programmatically by updating the bound collection.
Selected:
Theme Configuration
Styling is controlled by
TwBlazorTheme.Components (a TwCheckboxTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
| Property | Type | Controls |
|---|---|---|
Base |
string | |
Disabled |
string | |
Hover |
string | |
LabelBase |
string | |
LabelInteractiveCursor |
string | |
LabelNonInteractiveCursor |
string | |
LabelDisabled |
string | |
IconWrapper |
string | |
IndeterminateIconWrapper |
string |
Global Theme Configuration
These reuse shared design tokens configured once on TwBlazorTheme, rather than being unique to this component.
| Property | Type | Controls |
|---|---|---|
Colors |
TwBlazorPalette |
Full reference: TwCheckboxTheme on the API docs.