Skip to main content
On this page

Checkbox

Checkbox component for boolean selection with support for indeterminate state, labels, and multiple sizes.

import { Checkbox } from "@ninna-ui/forms";

pnpm add @ninna-ui/forms@latest
Includes @ninna-ui/core. CSS setup required.View source

Usage

Import and use the Checkbox component in your application.

import { Checkbox } from "@ninna-ui/forms";
export default function Example() {
return (
<Checkbox label="Accept terms and conditions" />
);
}

Basic

Click either the visible box or its label to toggle the native checkbox.

Live preview

Click the visible box or the label to toggle.

Checked: No

Variants

Checkbox supports outline, soft, and solid variants.

Live preview

Sizes

Checkbox comes in 3 sizes: sm, md, and lg.

Live preview

Colors

Checkbox supports multiple color themes.

Live preview

Label Position

Position the label on either side of the checkbox.

Live preview

Custom Icon

Use custom icons for the checked state.

Live preview

Indeterminate

Checkbox with indeterminate state for partial selection.

Live preview

States

Checkbox in different states: unchecked, checked, indeterminate, and disabled.

Live preview

With Description

Checkbox with label and description text.

Live preview
Receive emails about new products, features, and more.
Get notified about security updates and alerts.

React Hook Form

Checkbox works with React Hook Form using the Controller pattern. Use Field wrapper for error messages.

Live preview

API Reference

Complete list of props for the Checkbox component.

Checkbox Props

PropTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Size of the checkbox
color'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'danger''primary'Color theme of the checkbox
variant'outline' | 'soft' | 'solid''outline'Visual variant of the checkbox
checkedboolean—Controlled checked state
defaultCheckedboolean—Default checked state for uncontrolled usage
onCheckedChange(checked: boolean) => void—Callback when checked state changes
labelReactNode—Label text for the checkbox
descriptionReactNode—Description text below the label
labelPosition'start' | 'end''end'Position of the label relative to checkbox
invalidbooleanfalseWhether the checkbox is in an invalid state
iconReactNode—Custom icon for checked state
indeterminateIconReactNode—Custom icon for indeterminate state
disabledbooleanfalseWhether the checkbox is disabled
requiredbooleanfalseWhether the checkbox is required

Accessibility

  • Built on a native <input type="checkbox"> for full browser accessibility
  • Proper focus states with visible outlines
  • Supports keyboard navigation (Space to toggle)
  • The visible box and text label both activate the native checkbox
  • Labels are properly associated with checkboxes via htmlFor
  • Indeterminate state uses aria-checked="mixed" for screen readers