HextaUI

Checkbox: States

disabled, readOnly, indeterminate and aria-invalid. A read-only box keeps its value and stays focusable, but ignores clicks and keys.

import { Checkbox } from "@/components/ui/checkbox"

export function CheckboxStates() {
  return (
    <div className="flex flex-col gap-3 text-sm">
      <label className="flex items-center gap-3">
        <Checkbox disabled />
        Disabled
      </label>
      <label className="flex items-center gap-3">
        <Checkbox disabled defaultChecked />
        Disabled and checked
      </label>
      <label className="flex items-center gap-3">
        <Checkbox readOnly defaultChecked />
        Read-only
      </label>
      <label className="flex items-center gap-3">
        <Checkbox indeterminate />
        Indeterminate
      </label>
      <label className="flex items-center gap-3">
        <Checkbox aria-invalid />
        Invalid
      </label>
      <label className="flex items-center gap-3">
        <Checkbox aria-invalid defaultChecked />
        Invalid and checked
      </label>
    </div>
  )
}

This adds the example as components/examples/checkbox/states.tsx, together with the Checkbox component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/checkbox-states.json

To add only the component, follow the Checkbox installation.

Props in this example

The Checkbox props this example sets, from the API reference.

PropTypeDefault
defaultChecked
booleanfalse
indeterminateShows a dash: neither ticked nor unticked.
booleanfalse
disabled
booleanfalse
readOnlyFocusable, but the value can’t change.
booleanfalse

Every prop is in the Checkbox API reference.

See them all, with keyboard support and accessibility notes, on the Checkbox page.