Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Forms

Checkbox

A native checkbox for selecting one or more independent options.

Selector: input[type=checkbox][muiCheckbox]

Import
import { Checkbox } from '@mushilu-san/ui/forms';
PreviewCode

Loading example…

Overview

Checkbox is applied to a native <input type="checkbox">, so it keeps the native role, checked state and Space key behaviour. Pair it with a <label> so the whole label is clickable.

Set invalid to show the failed-validation styling (data-invalid) and to set aria-invalid="true". Link an error message with aria-describedby.

When to use

  • Choosing any number of options from a list, such as notification types.
  • Accepting a single yes/no agreement, such as terms of service.

When not to use

  • Choosing exactly one option from a set. Use radio buttons.
  • Switching a setting on or off that takes effect immediately. Use a toggle. Use Toggle instead.

Examples

Sizes and invalid state

PreviewCode

Loading example…

Guidelines

Do

  • Always label each checkbox with visible text.
  • Group related checkboxes under a shared heading or a fieldset with a legend.

Don't

  • Do not use a checkbox for a choice that has only one option. Use a toggle for an immediate setting.
  • Do not rely on colour alone to show the invalid state. Include an error message.

Accessibility

Roles and attributes

ElementRoleNotes
input[type=checkbox]checkbox (native)invalid sets data-invalid and aria-invalid="true".

Keyboard

KeysAction
TabShiftTabMoves focus to and from the checkbox.
SpaceToggles the checkbox.
  • Give each checkbox an accessible name from its label, or with aria-label when there is no visible label.

API

Checkbox

Selector: input[type=checkbox][muiCheckbox]

NameTypeDefaultDescription
size'sm' | 'md' | 'lg''md' Checkbox size: `sm`, `md` or `lg`. Default `md`.
invalidbooleanfalse Shows the failed-validation style and sets `data-invalid`. Also sets `aria-invalid`. Accepts attribute presence, e.g. <… invalid>.

CSS parts

  • ::part(checkbox)

Tokens

  • --mui-color-primary
  • --mui-color-border
  • --mui-color-danger
  • --mui-color-focus-ring
  • --mui-touch-target