Checkbox
Multi-select control. 3 values × 4 states.
import { Checkbox } from "@/components/ui/checkbox";
export default function Example() {
return <Checkbox label="Send me the weekly tea list" defaultChecked />;
}
Installation
$ npx uix-ui@latest add checkboxThis copies the file into components/ui/checkbox.tsx in your project. npx shadcn@latest add @uix/checkbox works too.
Usage
import { Checkbox } from "@/components/ui/checkbox";
<Checkbox label="Send me the weekly tea list" defaultChecked />
Examples
Mixed, nested and disabled
import * as React from "react";
import { Checkbox } from "@/components/ui/checkbox";
export default function Example() {
const [items, setItems] = React.useState({ tin: true, cup: false });
const all = items.tin && items.cup;
const some = items.tin || items.cup;
return (
<div style={{ display: "grid", gap: 12 }}>
<Checkbox label="Add everything" checked={all} indeterminate={some && !all} onChange={e => setItems({ tin: e.target.checked, cup: e.target.checked })} />
<div style={{ display: "grid", gap: 12, paddingLeft: 28 }}>
<Checkbox label="Darjeeling tin" checked={items.tin} onChange={e => setItems({ ...items, tin: e.target.checked })} />
<Checkbox label="Clay cup" checked={items.cup} onChange={e => setItems({ ...items, cup: e.target.checked })} />
</div>
<Checkbox label="Gift wrap (not available)" disabled />
</div>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | React.ReactNode | – | |
indeterminate | boolean | false | Shows the dash state (mixed selection). |
Everything else is passed to the root element, so className, aria-* and event handlers work as usual.
Dependencies
Installed for you by the CLI.
class-variance-authorityclsxtailwind-merge
lib/utils.tscomponents/ui/icons.tsx