Skip to content
synccn

Checkbox

Checked, unchecked and indeterminate, with label and description.

You agree to our terms of service and privacy policy.

Playground

Change the props and copy the code. The controls come from the component's TypeScript types.

You agree to our terms of service.

Props

defaultChecked
import { Checkbox } from "@/components/ui/checkbox";<Checkbox label="Accept terms" description="You agree to our terms of service." />

Installation

$ pnpm dlx shadcn@latest add @synccn/checkbox

First time in this project? Connect synccn with one command.

Usage

import { Checkbox } from "@/components/ui/checkbox";<Checkbox label="Accept terms" defaultChecked />

API reference

Generated from the component's TypeScript types, so it always matches the code.

  • checked
    boolean | "indeterminate"

    Controlled state.

  • defaultChecked
    boolean | "indeterminate"

    Default false

    Initial state when uncontrolled.

  • onCheckedChange
    (checked: boolean | "indeterminate") => void

    Called with the new state.

  • label
    React.ReactNode

    Clickable label.

  • description
    React.ReactNode

    Helper text under the label.

  • disabled
    boolean

    Prevents changes.

  • id
    string

    Id for the control; generated if omitted.

  • aria-label
    string

    Accessible name when there's no visible label (e.g. row checkboxes in a table).

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseControllable (works controlled or uncontrolled)

npm packages

Keyboard

  • SpaceToggle

Accessibility

  • role checkbox with aria-checked, including the mixed (indeterminate) state.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: checkbox
  • ARIA attributes: aria-checked, aria-label
  • Shows a visible focus ring for keyboard users
  • Labels are tied to their controls