Skip to content

Checkbox

The Checkbox component provides a customizable, accessible checkbox input. It’s built on top of the Radix UI Checkbox primitive with additional styling, and can render an optional label and caption alongside the box.

Installation

import { Checkbox } from "@harnessio/ui/components";
function Example() {
const [checked, setChecked] = React.useState(false);
return (
<Checkbox
id="accept-terms"
checked={checked}
onCheckedChange={setChecked}
label="Accept terms and conditions"
caption="You must accept terms and conditions to proceed."
/>
);
}

The checkbox works controlled (with checked + onCheckedChange) or uncontrolled (with defaultChecked). Set checked="indeterminate" for a partial-selection state.