Skip to Content
NarakUI

Checkbox

Select multiple options from a list.

Select all

A parent checkbox turns indeterminate while only some of its children are checked. Clicking it from there checks every child.

States

Unchecked, checked, indeterminate, disabled, and a custom check color.

Installation

pnpm dlx shadcn@latest add @narakui/checkbox

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/checkbox.json.

Usage

import { Checkbox } from '@/components/ui/checkbox';

<Checkbox checked={checked} onCheckedChange={setChecked}>
  Label
</Checkbox>

While indeterminate is true the box shows a minus and reports a mixed state to assistive technology, whatever checked is. Clicking it calls onCheckedChange(true).

Indicator only

CheckboxIndicator draws the box without an input. Use it inside a button, tree row, or other control that already handles the click.

import { CheckboxIndicator } from '@/components/ui/checkbox';

<CheckboxIndicator checked={isSelected} />

Checkbox Properties

PropTypeDefaultDescription
classNamestring—Additional CSS classes to apply to the label wrapper
childrenReact.ReactNode—The content to be displayed as the checkbox label
colorstring—Custom color for the checkbox when checked (CSS color value)
childrenWrapperClassNamestring—Custom class name for the children wrapper element
checkboxClassNamestring—Custom class name for the checkbox control
disableHoverbooleanfalseRemoves all hover feedback.
disablePaddingbooleanfalseRemoves the container padding. Hover then darkens the empty checkbox's border instead of filling a background.
readOnlybooleanfalsePrevent interaction with the checkbox while preserving appearance
indeterminatebooleanfalseShows the minus and reports a mixed state, whatever checked is. Clicking it calls onCheckedChange(true).
indeterminateIconReact.ReactNode<Minus />Custom icon for the indeterminate state
selectedIconReact.ReactNode<Check />Custom icon for the selected state
disabledbooleanfalseSet checkbox to a disabled, unclickable state
checkedboolean | 'indeterminate'—The controlled checked state of the checkbox
defaultCheckedboolean | 'indeterminate'—The default checked state when used as an uncontrolled component
onCheckedChange(checked: CheckedState) => void—Event handler called when the checked state changes. CheckedState is boolean or 'indeterminate'.
requiredboolean—When true, indicates that the user must check the checkbox before the owning form can be submitted
namestring—The name of the checkbox, used when submitting a form
valuestring'on'The value of the checkbox, used when submitting a form

CheckboxIndicator Properties

PropTypeDefaultDescription
checkedbooleanfalseShows the check mark
indeterminatebooleanfalseShows the minus mark. Wins over checked.
disabledbooleanfalseApplies the same disabled treatment as Checkbox
selectedIconReact.ReactNode<Check />Custom icon for the selected state
indeterminateIconReact.ReactNode<Minus />Custom icon for the indeterminate state
classNamestring—Additional CSS classes for the box