Skip to content
Nana UI

Forms & Inputs

Checkbox

A form-associated checkbox. Works inside a native <form>, supports the indeterminate state, and offers card / toggle tile variants for selection UIs.

View .md Download
Accept terms and conditions

The checkbox ships for all three targets. Pick the tab for your project — the CLI detects which you are on and serves the matching implementation.

npx @nana-tec/ui add checkbox

Lands as src/components/ui/checkbox/checkbox.tsx, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

import { Checkbox } from "@/components/ui/checkbox";
export function Example() {
const [accepted, setAccepted] = useState(false);
return (
<Checkbox
label="Accept terms"
description="You can withdraw consent at any time."
checked={accepted}
onChange={(event) => setAccepted(event.target.checked)}
/>
);
}

indeterminate is applied to the underlying input as a DOM property, so a partially-selected parent works without extra wiring. Every native <input> attribute passes through, and it forwards a ref.

Classes you pass to the React and Svelte components are merged with tailwind-merge, so an override wins rather than fighting. See Using Tailwind.

Small Medium Large
Checked Indeterminate Disabled Checked & disabled

The React and Svelte props, read from the components’ own types:

Checkbox

PropTypeDefault
sizeCheckboxSize'md'
indeterminatebooleanfalse
labelReactNode
descriptionReactNode
childrenReactNode

Also accepts Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type' | 'children'>.

The attribute names, events and CSS hooks below are the Web Components reference.

Properties

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseChecked state
descriptiondescriptionstring | undefined—Secondary descriptive text
disableddisabledbooleanfalseDisable the control
indeterminateindeterminatebooleanfalseIndeterminate (mixed) state — for "some children selected"
invalidinvalidbooleanfalseInvalid styling + state
labellabelstring | undefined—Convenience label text (slot wins if both are present)
loadingloadingbooleanfalseReplace the box with a spinner
namenamestring''Form field name
requiredrequiredbooleanfalseMark as required for form validation
sizesizeCheckboxSize'md'Control size
valuevaluestring'on'Submitted value when checked (default "on")
variantvariantCheckboxVariant'default'Visual style

Events

EventDescription
nana-changeFired on toggle (detail.checked, detail.indeterminate)

Slots

SlotDescription
(default)The label (overrides the label attribute)
descriptionSecondary descriptive text

CSS parts

PartDescription
::part(control)The clickable row
::part(box)The check box
::part(label)The label text

CSS custom properties

PropertyDescription
--nana-checkbox-accentChecked background / border colour
--nana-checkbox-radiusBox corner radius
--nana-checkbox-bgBox fill when unchecked
--nana-checkbox-borderBox border colour
--nana-checkbox-check-colorColour of the check mark itself
EventTypeDescription
nana-changeCustomEventFired on toggle (detail.checked, detail.indeterminate)
SlotDescription
(default)The label (overrides the label attribute)
descriptionSecondary descriptive text
VariableDescription
--nana-checkbox-accentChecked background / border colour
--nana-checkbox-radiusBox corner radius
PartDescription
controlThe clickable row
boxThe check box
labelThe label text
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Checkbox interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook