Forms & Inputs
@hacline/ui/checkboxCheckbox
Checkbox and checkbox group components built on @ui-sdk/react/checkbox with checked, indeterminate, disabled, and form integration support.
Import
import {
Checkbox,
CheckboxGroup,
CheckboxIndicator,
} from "@/components/ui/hacline/components/checkbox";Basic Usage and Groups
Includes built-in checkmark and indeterminate dash icons, with CheckboxGroup to manage multi-select values together.
<div className="flex w-full max-w-sm flex-col gap-4">
<Field name="terms" orientation="horizontal">
<Checkbox defaultChecked />
<FieldLabel>Agree to terms</FieldLabel>
</Field>
<Field name="partial" orientation="horizontal">
<Checkbox checked="indeterminate" />
<FieldLabel>Indeterminate state</FieldLabel>
</Field>
<Separator />
<CheckboxGroup defaultValue={["email"]}>
<label className="text-hl-fg inline-flex cursor-pointer items-center gap-2 text-sm">
<Checkbox value="email" />
Email notifications
</label>
<label className="text-hl-fg inline-flex cursor-pointer items-center gap-2 text-sm">
<Checkbox value="webhook" />
Webhook delivery
</label>
</CheckboxGroup>
</div>Select All and Indeterminate State
Compute the parent checkbox state from the number of selected items. Toggling "Select all exports" checks or clears the entire group.
"use client";
import { useId, useState } from "react";
import {
Checkbox,
CheckboxGroup,
} from "@/components/ui/hacline/components/checkbox";
import { Label } from "@/components/ui/hacline/components/label";
const exports = [
{ label: "Documentation", value: "notes" },
{ label: "Test logs", value: "tests" },
{ label: "Release artifacts", value: "artifacts" },
];
export const Example = () => {
const id = useId();
const [selected, setSelected] = useState(["notes"]);
let all: boolean | "indeterminate" = false;
if (selected.length) {
all = selected.length === exports.length ? true : "indeterminate";
}
return (
<div className="grid gap-2">
<div className="flex items-center gap-2">
<Checkbox
checked={all}
id={id}
onCheckedChange={(checked) => {
setSelected(checked ? exports.map(({ value }) => value) : []);
}}
/>
<Label htmlFor={id}>Select all exports</Label>
</div>
<CheckboxGroup
aria-label="Export items"
className="ps-4"
onValueChange={setSelected}
value={selected}
>
{exports.map(({ label, value }) => (
<label className="flex items-center gap-2 text-sm" key={value}>
<Checkbox value={value} />
{label}
</label>
))}
</CheckboxGroup>
</div>
);
};Props
Prop
Type