Checkbox

Material Design 3 checkbox component with multiple variants, sizes, and states

Checkbox

Checkboxes allow users to select one or more items from a set or toggle a single option. @duskmoon-dev/core provides a complete set of Material Design 3 checkbox variants with support for checked, indeterminate, and disabled states.

Basic Usage

Simply add the .checkbox class to an <input type="checkbox">:

Basic Checkbox

With Label

Wrap the checkbox in a label for better UX:

Checkbox with Label

Checked State

Checked Checkbox

Sizes

Five sizes are available:

Checkbox Sizes

Color Variants

Primary (Default)

Primary Checkbox

Secondary

Secondary Checkbox

Tertiary

Tertiary Checkbox

Success

Success Checkbox

Warning

Warning Checkbox

Error

Error Checkbox

Info

Info Checkbox

All Colors Comparison

All Color Variants

States

Indeterminate

The indeterminate (mixed) state represents a partially selected state, commonly used in “select all” scenarios. Set it via JavaScript:

Indeterminate Checkbox

Indeterminate Color Variants

All color variants support the indeterminate state:

Indeterminate Colors

Select All Pattern

A common use case for the indeterminate state is “select all” checkboxes:

Select All Example

Disabled

Disabled Checkboxes

Checkbox Groups

Vertical Group

Vertical Checkbox Group

Select your interests

Horizontal Group

Horizontal Checkbox Group

Form Integration

Checkbox in Form

Notification Preferences

Best Practices

Accessibility

  • Use semantic <label> elements to associate labels with checkboxes
  • Provide clear, descriptive labels
  • Use fieldset and legend for checkbox groups
  • Ensure sufficient color contrast

Touch Targets

The checkbox provides adequate touch targets. For mobile-first designs, use larger sizes:

Mobile-Friendly Checkbox

API Reference

Class Names

ClassDescription
.checkboxBase checkbox styling (required, on input element)
.checkbox-xsExtra small size (14px)
.checkbox-smSmall size (16px)
.checkbox-mdMedium size (20px, default)
.checkbox-lgLarge size (24px)
.checkbox-xlExtra large size (28px)
.checkbox-primaryPrimary color variant (default)
.checkbox-secondarySecondary color variant
.checkbox-tertiaryTertiary color variant
.checkbox-successSuccess color variant
.checkbox-warningWarning color variant
.checkbox-errorError color variant
.checkbox-infoInfo color variant
.checkbox-labelLabel wrapper for checkbox + text
.checkbox-groupContainer for vertical checkbox group
.checkbox-group-horizontalHorizontal layout modifier
.checkbox-group-labelGroup label text

HTML Structure

Simple checkbox:

<input type="checkbox" class="checkbox" />

With label:

<label class="checkbox-label">
  <input type="checkbox" class="checkbox" />
  <span>Label text</span>
</label>

States

StateHow to Apply
Checkedchecked attribute
Disableddisabled attribute
Indeterminateelement.indeterminate = true (JavaScript)
FocusAutomatic via :focus-visible
  • Radio - Single selection input
  • Switch - Toggle control
  • Input - Text input fields