Checkbox

A control that allows the user to toggle between checked and not checked.

Installation

bash
npx @smicolon/cli add checkbox

Run init once per project before adding components. See Installation.

Preview

With Label & Description

Receive emails about new products and features

Get notified about security updates

States

Props

PropTypeDefaultDescription
checkedboolean—Checked state. Use it with onChange.
indeterminatebooleanfalseShows a dash for a partly selected group.
disabledbooleanfalseDisables the checkbox and dims it.
errorbooleanfalseMarks the checkbox as invalid.
labelstring—Label text.
descriptionstring—Secondary line below the label.
namestring—Name submitted with the form.
valuestring—Value submitted when checked.
onChange(event) => void—Called when the checkbox changes.
classNamestring—Extra classes for the component.

Usage

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

// Basic checkbox
<Checkbox />

// With label
<Checkbox label="Accept terms and conditions" />

// With description
<Checkbox
  label="Marketing emails"
  description="Receive emails about new products"
/>

// Indeterminate state
<Checkbox indeterminate />

// Error state
<Checkbox label="Required field" error />