Checkbox
A styled native checkbox.
Token scopes
1 of 4 scopes granted
View code
let granted = new Set(["read"]);
function toggle(value: string, checked: boolean) {
if (checked) granted.add(value);
else granted.delete(value);
void handle.update();
}
<div mix={[vstack({ gap: 3, align: "stretch" })]}>
<span mix={[text("xs"), weight("semibold"), fg("neutral.muted")]}>Token scopes</span>
<Checkbox
checked={granted.size === SCOPES.length}
indeterminate={granted.size > 0 && granted.size < SCOPES.length}
aria-checked={granted.size === SCOPES.length ? "true" : "mixed"}
mix={[
ariaChecked(),
on<HTMLInputElement, "change">("change", (event) => {
granted = event.currentTarget.checked
? new Set(SCOPES.map((scope) => scope.value))
: new Set();
void handle.update();
}),
]}
>
<span mix={[weight("medium")]}>Grant every scope</span>
</Checkbox>
<Separator />
{SCOPES.map((scope) => (
<Checkbox
key={scope.value}
name="scopes"
value={scope.value}
checked={granted.has(scope.value)}
color={scope.value === "secrets" ? "danger" : "brand"}
mix={[
ariaChecked(),
on<HTMLInputElement, "change">("change", (event) =>
toggle(scope.value, event.currentTarget.checked),
),
]}
>
<span mix={[vstack({ gap: 0, align: "start" })]}>
<span mix={[text("sm")]}>{scope.label}</span>
<span mix={[text("xs"), fg("neutral")]}>{scope.hint}</span>
</span>
</Checkbox>
))}
<p mix={[pis(7), text("sm"), fg("neutral")]}>
{granted.size} of {SCOPES.length} scopes granted
</p>
</div>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/uiimport "@sdxc/ui/theme.css";Usage
import { Checkbox } from "@sdxc/ui";The box precedes the input in source order so its :has(~ input:…) rules
can read state directly off it, keeping the whole control CSS-driven;
shrink(0) also keeps the box square regardless of label length.
Examples
<Checkbox color="danger" checked={row.flagged} aria-label={t("table.flagRow")} /><Checkbox disabled defaultChecked>{t("settings.legacyOptIn")}</Checkbox>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Description |
|---|---|---|
role? | "checkbox" | "button" | "menuitemcheckbox" | "option" | "switch" | ARIA role override, restricted to what a checkbox input may carry. |
color? | "brand" | "neutral" | "success" | "warning" | "danger" | Semantic color role. Defaults to DEFAULT_COLOR. |
children? | RemixNode | Label content rendered after the box, inside the same native <label> wrapping the row — clicking any of it toggles the checkbox natively, with no separate htmlFor/id pair required. |
parts? | PartsProps | Per-part styling for this wrapper's internally composed elements. |
Also accepts everything in Omit<TagProps<"input">, "type" | "role">.
Types
| Name | Values | What it decides |
|---|---|---|
Color | "brand" | "neutral" | "success" | "warning" | "danger" | Semantic color role, each mapped to its matching --ui-* variables. |