Checkbox
Checkbox captures independent boolean or multi-select choices.
@duskmoon-dev/components/checkbox Usage
When to use
- Use it inside forms, filters, settings, and any workflow that captures user input.
- Prefer controlled props when the value must stay synchronized with application state.
Implementation notes
Features
Documents default values, value props, and change callbacks for form integration.
Surfaces status, size, disabled, and option data patterns where the component supports them.
Checkbox is most often configured through `color`, `size`, `indeterminate`, `error`.
Renders with default classes
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Colors
Checkbox supports the full semantic color palette: primary, secondary, tertiary, accent, neutral, base, info, success, warning, error.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
const colors = [
"primary",
"secondary",
"tertiary",
"accent",
"neutral",
"base",
"info",
"success",
"warning",
"error"
] as const;
export function CheckboxColorsDemo() {
return (<div style={{ display: "grid", gap: 8 }}>
{colors.map((color) => (
<Checkbox key={color} color={color} defaultChecked>
{color}
</Checkbox>
))}
</div>);
} Basic usage
Import the component stylesheet and Checkbox from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
export function Example() {
return (<Checkbox
color="primary"
>
DuskMoon Checkbox
</Checkbox>);
} Renders with default classes
test-backedCheckbox scenario from the component test coverage: renders with default classes.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
export function CheckboxRendersWithDefaultClassesDemo() {
return (<Checkbox
// Renders with default classes
color="primary"
>
DuskMoon Checkbox
</Checkbox>);
} Applies checked and indeterminate state
test-backedCheckbox scenario from the component test coverage: applies checked and indeterminate state.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
export function CheckboxAppliesCheckedAndIndeterminateDemo() {
return (<Checkbox
// Applies checked and indeterminate state
color="primary"
>
DuskMoon Checkbox
</Checkbox>);
} Calls native change handler
test-backedCheckbox scenario from the component test coverage: calls native change handler.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
export function CheckboxCallsNativeChangeHandlerDemo() {
return (<Checkbox
// Calls native change handler
color="primary"
>
DuskMoon Checkbox
</Checkbox>);
} Applies size, color, error, loading, and label position classes
test-backedCheckbox scenario from the component test coverage: applies size, color, error, loading, and label position classes.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
export function CheckboxAppliesSizeColorErrorDemo() {
return (<Checkbox
// Applies size, color, error, loading, and label position classes
color="primary"
>
DuskMoon Checkbox
</Checkbox>);
} Forwards input ref
test-backedCheckbox scenario from the component test coverage: forwards input ref.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
export function CheckboxForwardsInputRefDemo() {
return (<Checkbox
// Forwards input ref
color="primary"
>
DuskMoon Checkbox
</Checkbox>);
} Includes component stylesheet rules
test-backedCheckbox scenario from the component test coverage: includes component stylesheet rules.
import "@duskmoon-dev/components/styles.css";
import { Checkbox } from "@duskmoon-dev/components/checkbox";
export function CheckboxIncludesComponentStylesheetRulesDemo() {
return (<Checkbox
// Includes component stylesheet rules
color="primary"
>
DuskMoon Checkbox
</Checkbox>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Checkbox
color="primary"
>
DuskMoon Checkbox
</Checkbox>
</div>
<div data-theme="moonlight">
<Checkbox
color="primary"
>
DuskMoon Checkbox
</Checkbox>
</div> API
The API reference below lists every parsed exported type or interface for Checkbox. Start with `color`, `size`, `indeterminate`, `error` for common usage.
packages/components/src/components/checkbox/Checkbox.types.ts
Scenarios: packages/components/src/components/checkbox/Checkbox.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
color | CheckboxColor | No | color configures Checkbox. |
size | CheckboxSize | No | size configures Checkbox. |
indeterminate | boolean | No | indeterminate configures Checkbox. |
error | boolean | No | error configures Checkbox. |
loading | boolean | No | loading configures Checkbox. |
labelPosition | CheckboxLabelPosition | No | labelPosition configures Checkbox. |
className | string | No | className configures Checkbox. |
children | ReactNode | No | children configures Checkbox. |
onChange | (event: ChangeEvent<HTMLInputElement>) => void | No | onChange configures Checkbox. |
| "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error" "sm" | "md" | "lg" "left" | "right"