Checkbox

React Checkbox components are used to let users select one or more options from a list. They are commonly used in forms, settings panels, and preference selections.

This Checkbox component is built with React Aria Components' Checkbox and styled using Tailwind CSS and the Tailgrids theme tokens. It keeps native checkbox semantics, supports indeterminate and invalid states, and lets the label be the component's children.

Installation

npx @tailgrids/cli@latest add checkbox

Usage

Import the component and pass the label as children. Without a visible label, provide an accessible name with aria-label.

import { Checkbox } from "@/components/tailgrids/checkbox";

export default function CheckboxExample() {
  return <Checkbox defaultSelected>Accept terms and conditions</Checkbox>;
}

Examples

Sizes

The Checkbox component supports two sizes: sm (default) and md.

With Label

Pass the label as the checkbox's children. Use isIndeterminate for a partially selected state.

Controlled

Control the state with isSelected and onChange. onChange receives the new boolean value.

Not subscribed

API Reference

Checkbox

Extends React Aria's Checkbox props.

PropTypeDefaultDescription
size'sm' | 'md''sm'Checkbox size
childrenReactNode-The label displayed next to the checkbox
isSelectedboolean-Controlled selected state
defaultSelectedboolean-Initial selected state when uncontrolled
onChange(isSelected: boolean) => void-Called with the new state when it changes
isIndeterminatebooleanfalseShows the mixed state
isDisabledbooleanfalseDisables the checkbox
isReadOnlybooleanfalseMakes the checkbox read-only
isRequiredbooleanfalseMarks the checkbox as required
isInvalidbooleanfalseShows the invalid state
aria-labelstring-Accessible name when no visible label is used
classNamestring-Additional classes for the root element

Accessibility

  • Uses a visually hidden native <input type="checkbox"> with standard keyboard support
  • The label is associated automatically; without a visible label, set aria-label
  • Fully keyboard accessible with standard checkbox behavior (Space toggles)
  • Visible focus ring provides clear keyboard feedback
  • Disabled, invalid and indeterminate states are exposed to assistive technology

On this page

Tailgrids Pro

Access 600+ blocks, components and templates - built for speed, consistency, and scale.

Get Tailgrids Pro