Checkbox
A labelled checkbox with geometric icon morphing, indeterminate state, semantic fill tones, and configurable fill animations and box shapes.
import { Checkbox } from '@uthereal/ui/checkbox'Checkbox playground
Overview
Checkbox renders a native checkbox inside the inline field anatomy: the box beside its label, with optional description and error text below the label. It supports unchecked, checked, and indeterminate states, a three-tier morphing mark engine, semantic fill tones, three fill animations, and rounded or circular boxes.
Your application owns the checked state and form validation. Checkbox reports every toggle through onCheckedChange and never opens native browser validation bubbles.
| Capability | Behavior |
|---|---|
| States & forms | true, false, or 'indeterminate' (toggling from indeterminate checks it); submits value under name while checked |
| Mark morphing | Default check-to-dash path morph, six bidirectional geometric pairs plus heart, or spring cross-morph for any curated icon |
| Tones & fills | tone sets the active fill and contrasting glyph (neutral, accent, status tones); fillAnimation picks scale, radial, or wipe |
| Shape & size | shape switches between rounded and circle; sm–lg step the box (16, 18, 20 px) inside a control-height hit target |
Use Checkbox for independent choices, multi-item selection, or consent confirmed on submit. Use Switch for settings that take effect immediately, Radio for mutually exclusive choices, and Multiselect for long or searchable option lists.
Usage
'use client'
import { useState } from 'react'
import { Checkbox } from '@uthereal/ui/checkbox'
export function TermsConsent() {
const [accepted, setAccepted] = useState(false)
return (
<Checkbox
label="I accept the terms of service"
name="terms"
required
checked={accepted}
onCheckedChange={(checked) => setAccepted(checked === true)}
/>
)
}Omit checked for an uncontrolled checkbox initialized from defaultChecked; onCheckedChange still fires on every toggle. In HTML forms, the hidden <input type="checkbox"> submits value ("on" by default) under name while checked, and form reset restores defaultChecked.
To build a select-all checkbox, derive checked from the items it controls (true when all are selected, 'indeterminate' when some are, false when none are) and update every item in onCheckedChange.
Examples
Morphing marks and states
The default check and minus marks share SVG path coordinates so they morph smoothly between checked and indeterminate. Pairing plus↔check, copy↔check, play↔pause, sun↔moon, menu↔x, or bell-off↔bell in either direction—or using checkedIcon="heart"—activates true geometric stroke morphing. Any other curated checkedIcon, uncheckedIcon, or indeterminateIcon cross-morphs on a spring.
Tones, fills, shapes, and field states
Set tone (neutral, accent, info, success, warning, danger) to color the active fill and automatically pick a contrasting glyph color. Combine fillAnimation (scale, radial, or wipe) with shape="circle" for task lists or custom toggles, and use description, required, error, or disabled for form states.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Accept terms" | Visible label and accessible name. State the choice in sentence case, e.g. "Email me product updates". |
hideLabel | booleanDefault: false | Hide the label visually when the context already names the field. It is still announced. |
description | string— | Supporting text below the label, announced with the checkbox. Use it for consequences or details. |
error | string— | Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely. |
required | booleanDefault: false | Marks the checkbox as required for assistive technology and shows an indicator, e.g. for accepting terms. Your application validates it. |
disabled | booleanDefault: false | Unavailable and removed from the tab order. A disabled checkbox is not submitted with a form. |
name | string— | Native form field name, submitted with the value in a form. |
defaultChecked | boolean | 'indeterminate'Default: false | Initial state: true, false, or "indeterminate" for a partly selected set. Later argument edits do not reset an existing instance; use checked and onCheckedChange to control it. |
value | stringDefault: "on" | Value submitted with a form while the checkbox is checked. Defaults to "on", like a native checkbox. |
checkedIcon | IconNameDefault: "check" | Mark shown while checked. The default check draws in and morphs continuously into the indeterminate dash; plus-to-check, copy-to-check, play-to-pause, sun-to-moon, menu-to-x, bell-off-to-bell (in either direction), and heart morph geometrically; any other curated icon cross-morphs. |
uncheckedIcon | IconName— | Subtle mark shown while unchecked, e.g. plus, copy, bell-off, or a hollow heart, so the box is never empty. Pairs such as plus to check, copy to check, or sun to moon morph geometrically between the two states. |
indeterminateIcon | IconNameDefault: "minus" | Mark shown while indeterminate. The default minus shares points with the check, so the two morph into each other. |
tone | neutral | accent | info | success | warning | dangerDefault: "neutral" | Color of the active fill and its edge: neutral (the standard chosen-control color), accent, or a status tone such as success for a completed choice. |
fillAnimation | scale | radial | wipeDefault: "scale" | How the active fill appears: scale (the default spring scale from the center), radial (a circular bloom), or wipe (a bottom-to-top sweep). |
shape | rounded | circleDefault: "rounded" | Box shape: rounded corners (the default) or a full circle. |
size | sm | md | lgDefault: "md" | Box of 16, 18 (Arc), or 20 pixels in a hit box one control tall. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | CheckboxTheme— | Color mode, accent, and tokens, including boxSize and boxRadius. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | The fill animation, the mark drawing and morphing, and the press. none and system reduced-motion preferences make them immediate. |
motionOptions | CheckboxMotionOptions— | Fine-grained motion overrides: pressScale, and the fill and mark transitions (durations in ms). |
dir | ltr | rtl— | Reading direction; the box sits at the inline start. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
checked, onCheckedChange | Control the state (true, false, or 'indeterminate'). Callback fires in both modes. |
renderIcon(state) | Replaces the built-in mark inside the box for the current CheckedState (no fallback on null). |
ref | Ref to the native <input type="checkbox"> element. |
id | Control id; label, description, and error ids derive from it. |
preset | Application defaults (such as size, tone, shape, theme), overridden by instance props. |
tokens | CSS custom properties (--ui-*) applied after the typed theme on the field root. |
className, style | Applied to the outer field root, which carries the resolved --ui-* tokens. |
| Native attributes | Forwarded to <input> (autoFocus, form, onFocus, onBlur, aria-*, data-*, and others). |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Moves focus to or from the checkbox. |
Space | Toggles it; indeterminate becomes checked. |
Checkbox wraps a visually hidden native <input type="checkbox"> inside a square hit target one control tall (44 px at md), preserving native forms, autofill, and assistive technology semantics (including mixed for indeterminate). The label names the input through both <label> association and aria-labelledby, so hideLabel stays announced. description and error link via aria-describedby, error sets aria-invalid and renders in a role="alert" region, and required sets aria-required without triggering browser validation bubbles.
In dir="rtl", inline-field layout mirrors from the inline start. Under forced-colors: active, unchecked boxes use ButtonText, checked and indeterminate boxes use Highlight fill with HighlightText glyphs, disabled boxes stay at full opacity (GrayText outline when unchecked; GrayText fill with Canvas glyph when checked), invalid boxes add a CanvasText inner outline, and focus rings use Highlight.
Motion and theming
- Active fill:
scalescales from0.6to1,radialblooms a circle from0to1.5, andwipesweeps upward fromscaleY(0)to1, all onmotionOptions.fill(Arc'ssnappyspring). Fills keep their tone background during exit so unchecking animates out cleanly. - Mark transitions: the default check/dash path draws and morphs on
motionOptions.mark(Arc'smorphspring); geometric icon-morph pairs stay mounted across unchecked↔checked and swap cleanly only forindeterminate; custom icon pairs cross-morph with scale, slight rotation, and blur onmotionOptions.mark. - Press & reduced motion: pressing scales only the box to
motionOptions.pressScale(0.92) and springs back on release. Settingmotion="none"or enablingprefers-reduced-motion: reducemakes fill, mark, color, and press transitions immediate (0ms).
theme accepts the core and control token groups, plus borderStrong, controlOn, controlGlyph, status tones (info, success, warning), toneForeground, and box geometry (boxSize, boxRadius). Disabled boxes use disabledOpacity while labels stay readable. Supply application-wide defaults with UtherealProvider.
Composition
Checkbox is a leaf component. Its checked state is host state at /fields/instance-<id>/checked, initialized from defaultChecked, and preserved when an agent edits other arguments. See Building with agents.
{
"type": "Checkbox",
"props": {
"label": "Email me product updates",
"description": "About once a month. Unsubscribe at any time."
},
"children": []
}