Checkbox
A control that allows the user to toggle between checked and not checked.
import { Checkbox } from "@dapplelight/signet-ui/components/checkbox"
export function Demo() {
return (
<div className="flex items-center gap-2">
<Checkbox id="terms" />
<label htmlFor="terms" className="text-sm">Accept terms and conditions</label>
</div>
)
}Installation
npm i @dapplelight/signet-uiUsage
import { Checkbox } from "@dapplelight/signet-ui/components/checkbox"
<Checkbox />Examples
Checked
import { Checkbox } from "@dapplelight/signet-ui/components/checkbox"
<Checkbox id="receipts" defaultChecked />
<label htmlFor="receipts">Email me receipts</label>Disabled
import { Checkbox } from "@dapplelight/signet-ui/components/checkbox"
<Checkbox id="sso" disabled />
<label htmlFor="sso">Enforce SSO (Enterprise plan)</label>Controlled
1 selected
import * as React from "react"
import { Checkbox } from "@dapplelight/signet-ui/components/checkbox"
import { invoices, toggle } from "./invoices"
const [selected, setSelected] = React.useState<string[]>(["INV-2041"])
{invoices.map((id) => (
<div key={id} className="flex items-center gap-2">
<Checkbox
id={id}
checked={selected.includes(id)}
onCheckedChange={(v) => toggle(id, v === true)}
/>
<label htmlFor={id}>{id}</label>
</div>
))}API Reference
Checkbox
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | "indeterminate" | - | Controlled state. |
defaultChecked | boolean | "indeterminate" | - | Initial state when uncontrolled. |
onCheckedChange | (checked: boolean | "indeterminate") => void | - | Runs when the state changes. |
disabled | boolean | false | Prevents interaction. |
required | boolean | false | Marks it required in a form. |
name | string | - | Form field name. |
value | string | "on" | Form value when checked. |
className | string | - | Merged last. |
Built on a Radix checkbox, so it takes every button prop. Pair it with a label using id and htmlFor.