Checkbox

A React checkbox on Base UI with checked, unchecked, and indeterminate states, labels, descriptions, errors, checkbox groups, and selectable cards.

Loading preview

Examples

Practical examples and common states for the same installable component.

Soft

Rounded muted checkbox with a quieter selected state.

examples/checkbox-soft.tsx
import { Checkbox } from "@/components/wensity/checkbox";
export function CheckboxSoft() {
return (
<Checkbox
variant="soft"
defaultChecked
label="Enable smart suggestions"
description="Use recent activity to improve recommendations."
/>
);
}

Group

Group related checkbox choices with shared label and description.

examples/checkbox-group.tsx
"use client";
import * as React from "react";
import { Checkbox, CheckboxGroup } from "@/components/wensity/checkbox";
export function CheckboxGroupDemo() {
const [values, setValues] = React.useState({
email: true,
inApp: true,
sms: false,
});
return (
<CheckboxGroup label="Notification channels">
<Checkbox
label="Email"
checked={values.email}
onCheckedChange={(checked) =>
setValues((current) => ({ ...current, email: checked }))
}
/>
<Checkbox
variant="soft"
label="In-app inbox"
checked={values.inApp}
onCheckedChange={(checked) =>
setValues((current) => ({ ...current, inApp: checked }))
}
/>
<Checkbox
variant="soft"
label="SMS"
checked={values.sms}
onCheckedChange={(checked) =>
setValues((current) => ({ ...current, sms: checked }))
}
/>
</CheckboxGroup>
);
}

Permissions

Card checkbox rows for settings, roles, and permission lists.

examples/checkbox-permissions.tsx
import { CheckboxCard, CheckboxGroup } from "@/components/wensity/checkbox";
export function CheckboxPermissions() {
return (
<CheckboxGroup label="Team permissions">
<CheckboxCard
label="Manage members"
description="Invite teammates, edit roles, and remove access."
defaultChecked
trailing="Admin"
/>
<CheckboxCard
label="Edit registry"
description="Create, update, and publish component entries."
defaultChecked
variant="soft"
trailing="Editor"
/>
<CheckboxCard
label="View analytics"
description="Read usage, downloads, and conversion reports."
trailing="Viewer"
/>
</CheckboxGroup>
);
}

Indeterminate

Mixed state for table headers and bulk selection.

examples/checkbox-indeterminate.tsx
"use client";
import * as React from "react";
import {
Checkbox,
type CheckboxCheckedState,
} from "@/components/wensity/checkbox";
export function CheckboxIndeterminate() {
const [state, setState] =
React.useState<CheckboxCheckedState>("indeterminate");
return (
<Checkbox
checked={state}
onCheckedChange={(checked) => setState(checked)}
label="Select visible rows"
description="Useful for table headers and bulk actions."
/>
);
}

Error

Validation state with error copy connected through aria-describedby.

examples/checkbox-error.tsx
import { Checkbox } from "@/components/wensity/checkbox";
export function CheckboxError() {
return (
<Checkbox
label="I understand the billing impact"
description="Required before changing plan limits."
error="Confirm this before continuing."
/>
);
}

Disabled

Disabled states keep the row readable while blocking interaction.

examples/checkbox-disabled.tsx
import { Checkbox } from "@/components/wensity/checkbox";
export function CheckboxDisabled() {
return (
<div className="space-y-4">
<Checkbox disabled label="SAML single sign-on" />
<Checkbox
disabled
defaultChecked
variant="soft"
label="Audit logging"
/>
</div>
);
}

Settings

A realistic settings list using checkbox cards for independent choices.

examples/checkbox-settings.tsx
import { CheckboxCard } from "@/components/wensity/checkbox";
export function CheckboxSettings() {
return (
<div className="space-y-3">
<CheckboxCard
label="Weekly product digest"
description="A concise summary of new components and fixes."
defaultChecked
/>
<CheckboxCard
label="Realtime billing alerts"
description="Send a notification when usage crosses plan limits."
defaultChecked
/>
<CheckboxCard
label="Security review required"
description="Require admin approval for new API tokens."
variant="soft"
/>
</div>
);
}

Overview

Checkbox is a React and Tailwind CSS checkbox built on Base UI, in Next.js or any React app, with checked, unchecked, and indeterminate states. Pass checked as indeterminate for a select all row whose children are partly picked, and the box shows a dash instead of a tick. Each checkbox carries its own label, description, and error, linked for screen readers, and the small size keeps a larger touch target. CheckboxGroup wraps rows in a fieldset with a legend, and CheckboxCard turns a row into a selectable card. onCheckedChange only reports true or false, so derive the mixed state.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add checkbox

Usage

Import Checkbox from @/components/wensity/checkbox and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
import { Checkbox } from "@/components/wensity/checkbox";
export function CheckboxDemo() {
return (
<Checkbox
defaultChecked
label="I agree to the terms and privacy policy"
description="You can review both documents before continuing."
/>
);
}

Props

PropTypeDefaultDescription
checkedboolean | "indeterminate"-Controlled checked state. The indeterminate value renders the mixed dash.
defaultCheckedboolean | "indeterminate"falseInitial state when the checkbox is uncontrolled.
onCheckedChange(checked: boolean, eventDetails?: unknown) => void-Called when the checked state changes.
labelReact.ReactNode-Label beside the control, wired to it so the text is clickable.
descriptionReact.ReactNode-Secondary copy under the label.
errorReact.ReactNode-Error message under the control, with invalid styling applied.
checkboxSize"sm" | "md" | "lg""md"Size of the control box and its label text.
variant"classic" | "soft""classic"classic fills on check; soft uses a tinted surface.
fullWidthbooleantrueStretches the row to fill its container.
containerClassNamestring-Classes for the row wrapper around control and label.
controlClassNamestring-Classes for the checkbox control itself.
  • Fluid Drag-and-Drop Kanban component preview

    Fluid Drag-and-Drop Kanban

    A Trello-grade board running real pointer physics, where every card tilts toward the velocity you throw it across at.

  • Subscription Tier Card component preview

    Subscription Tier Card

    Pricing cards with a monthly and annual toggle, prices that spring to new values, and a highlighted plan in a brand glow.

  • Multi-Step Form Wizard component preview

    Multi-Step Form Wizard

    A multi-step form wizard whose card physically reshapes to wrap each new step as the content slides in behind it.

  • Multi-Select Tag Input component preview

    Multi-Select Tag Input

    A tag input where pills pop in as you add them and slide out on remove, closing the gap without snapping the layout.