Infragistics
Close
Angular React Web Components Blazor Blazor
Open Source

Blazor Checkbox Component

The Blazor Checkbox is a component that lets you add checkboxes to your Blazor apps. It behaves as a standard HTML checkbox, enabling users to select basic checked and unchecked states or an additional indeterminate state. You also get full control over the styling of the Blazor checkbox component and ability to use it with forms.

Live Demo

Anatomy

The Blazor Checkbox renders a selectable control with an optional label.

Checkbox anatomy showing the indicator and optional label
1. Checkbox Indicator: indicates the current state. By default it is unselected. Could be before or after the label
2. Label (optional): specifies the target data available for selection and deselection

The Blazor Checkbox consists of an indicator and optional label content. Set the label position when the label should appear before or after the indicator.

Checkbox
├── Checkbox Indicator
└── Label (optional)

Getting Started

To use the Blazor Checkbox, follow the Ignite UI for Blazor Getting Started topic for the basic project setup, then install or register the component for your target platform.

Register the Ignite UI for Blazor services:

// in Program.cs file

builder.Services.AddIgniteUIBlazor();

Registering IgbCheckboxModule, the Checkbox’s client resource module, is optional: the component loads its resources when it first renders. Listing it in builder.Services.AddIgniteUIBlazor(typeof(IgbCheckboxModule)) can be used to preload resources or to support elements created only on the client (see Component Modules).

Then link the theme CSS file in the app’s host page (wwwroot/index.html in a standalone Blazor WebAssembly or Blazor Hybrid app, Pages/_Host.cshtml in a Blazor Server app, Components/App.razor in a Blazor Web App):

<link href="_content/IgniteUI.Blazor/themes/light/bootstrap.css" rel="stylesheet" />

After registration, render the IgbCheckbox with the platform-specific element or wrapper:

<IgbCheckbox />

The IgbCheckbox component doesn’t work with a standard HTML <form> element in Blazor. Use the Blazor EditForm component instead.

Usage

At its core, the IgbCheckbox lets users choose between selected and unselected states, with support for an indeterminate state when an option represents a partial selection.

You can specify if the label should be positioned before or after the checkbox toggle by setting the LabelPosition attribute of the checkbox. Allowed values are before and after (default):

<IgbCheckbox LabelPosition="@ToggleLabelPosition.Before">Label</IgbCheckbox>

The checkbox can also be labelled by elements external to the checkbox. In this case, the user is given full control to position and style the label in accordance with their needs.

<span id="checkbox-label">Label</span>
<IgbCheckbox AriaLabelledBy="checkbox-label" />

States

The Checkbox supports different state-related attributes. You can use the checked attribute to set the initial state of the checkbox to on or off.

<IgbCheckbox Checked="true" />

You can use the indeterminate attribute to set the checkbox’s value to neither true nor false.

<IgbCheckbox Indeterminate="true" />

You can use the disabled attribute to disable the Checkbox.

<IgbCheckbox Disabled="true" />

You can use the invalid attribute to mark the Checkbox as invalid.

<IgbCheckbox Invalid="true" />

You can use the required property to mark the Checkbox as required.

<IgbCheckbox Required="true" />

Do/Don’t

When many Checkboxes are necessary, arrange them in a column group so users can quickly scan the list. Fewer Checkboxes may be arranged on a single line next to each other, but avoid arranging them in multiple columns.

Checkboxes arranged in a single vertical column Checkboxes arranged in multiple columns

Do

Stack checkboxes vertically in a single column to make options easy to scan and read.

Don’t

Avoid arranging checkboxes into multiple columns, as this breaks vertical reading patterns and makes scanning difficult.

Properties

The following properties cover the main Checkbox configuration options documented on this page. See the full API reference for the complete generated list.

Name Type Default Description
checked boolean false Gets or sets whether the checkbox is selected.
indeterminate boolean false Gets or sets whether the checkbox is in an indeterminate state.
labelPosition ToggleLabelPosition after Sets the position of the checkbox label.
required boolean false Gets or sets whether the Checkbox is required.
invalid boolean false Gets or sets whether the Checkbox is invalid.
disabled boolean false Gets or sets whether the Checkbox is disabled.
value string — Gets or sets the value used when the Checkbox is submitted with a form.

Styling

The Blazor Checkbox uses CSS parts and CSS variables to customize its appearance.

Sass Theming

Use the Ignite UI for Blazor theme system to style the Checkbox consistently with the rest of your application. Verify the available Sass theme parameters in the API documentation before adding a custom theme.

CSS Variables

Use the following styling properties to customize the Checkbox indicator and selected-state appearance:

Variable What it changes
--tick-color The color of the check icon.
--fill-color The background color of the selected checkbox.

Style Parts

Use the following CSS parts to target the Checkbox structure:

Part What it styles
base The base wrapper of the Checkbox.
control The checkbox control element.
indicator The checkbox indicator icon.
label The Checkbox label.

Custom Styling

The following selectors customize the Checkbox indicator color and selected-state fill:

Selector Declaration Effect
igc-checkbox::part(indicator) --tick-color Changes the check icon color.
igc-checkbox::part(control checked)::after --fill-color Changes the selected checkbox background color.
igc-checkbox::part(indicator) {
  --tick-color: var(--ig-secondary-500-contrast); /* check icon color */
}
igc-checkbox::part(control checked)::after {
  --fill-color: var(--ig-secondary-500); /* checkbox background color */
}

Styling with Tailwind

You can style the Blazor Checkbox with the custom Tailwind utility classes from igniteui-theming. Make sure to set up Tailwind first, then import the Ignite UI utilities in your global stylesheet:

@import "tailwindcss";
@import "igniteui-theming/tailwind/utilities/material.css";
<IgbCheckbox Class="![--tick-color:var(--ig-secondary-500)]" />

The exclamation mark (!) gives the Tailwind utility precedence over the Checkbox’s default theme styles.

Accessibility

The Blazor Checkbox provides a selectable control with a label and state that must remain understandable for keyboard and assistive technology users.

Keyboard Interaction

The Checkbox uses the keyboard behavior provided by its rendered control. A disabled Checkbox is not keyboard interactive, and the Space key changes its checked state.

Use the keyboard interaction provided by the Checkbox and verify the focus and state-change behavior for the target platform.

Key / interaction Action
Tab / Shift+Tab Moves focus to or away from the Checkbox when it is enabled and focusable.
Space Toggles the checked state of the focused Checkbox.
Indeterminate state The Checkbox exposes its current state when the indeterminate state is enabled.

Screen Readers / ARIA

The Checkbox exposes its checked state, disabled state, and, when configured, required, invalid, and indeterminate states through the semantics of its rendered control.

  • Provide meaningful label content for every Checkbox so assistive technology users can identify its purpose.
  • When the label is outside the component, connect it with the supported labelling mechanism and verify the announcement in the target platform.
  • Preserve the Checkbox state semantics when customizing or wrapping the control.
  • Change event handlers report state changes; they do not replace the accessible name or state.

The checked, unchecked, required, invalid, disabled, and indeterminate states must remain available to assistive technology through the component’s supported semantics. Verify the rendered announcement against the platform API documentation.

Accessibility Compliance

Verify the rendered Blazor Checkbox against the accessibility requirements of the application.

Criterion How the component supports the requirement
2.1.1 Keyboard The enabled Checkbox can receive keyboard focus and its checked state can be changed with Space.
4.1.2 Name, Role, Value The Checkbox exposes its accessible name and current selection state through the rendered control and supported state semantics.
3.3.1 Error Identification When the Checkbox is invalid, expose the validation state and provide an appropriate message in the surrounding form.

Your responsibilities:

  • Give every Checkbox a meaningful accessible name.
  • Keep focus visible and preserve sufficient contrast when customizing the Checkbox theme.
  • Ensure required, invalid, disabled, and indeterminate states are also communicated when visual styling alone is insufficient.
  • Test the rendered Checkbox with keyboard navigation and supported assistive technologies.

API References

Dependencies

The Blazor Checkbox requires a theme stylesheet to apply its visual styling. See the framework-specific setup in Getting Started.

Additional Resources

Use the following Blazor resources for API details and project support:

The Blazor Checkbox is intended for selectable form options. Use the following related component when you need an immediate on/off action instead:

FAQ

These frequently asked questions cover common Blazor Checkbox selection, accessibility, form, and validation scenarios.

Can I use the Checkbox with a form?

Use the Blazor EditForm component instead of a standard HTML <form> and bind the checked state of the Checkbox to your model.

How do I show a partially selected Checkbox?

The Blazor Checkbox supports a third, indeterminate state for partially selected options. Set the indeterminate property to enable that state.

How do I provide an accessible Checkbox label?

The Blazor Checkbox should have meaningful label content so assistive technology users can identify its purpose. When the label is outside the component, connect it with the supported labelling mechanism such as aria-labelledby.

How do I mark a Checkbox as required or invalid?

Set the required property to indicate that the Checkbox must be selected and the invalid property to expose a validation state. Provide an appropriate validation message in the surrounding form when the Checkbox is invalid.