UI

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

Show projects that are no longer active.
Loading interactive preview…

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.

CapabilityBehavior
States & formstrue, false, or 'indeterminate' (toggling from indeterminate checks it); submits value under name while checked
Mark morphingDefault check-to-dash path morph, six bidirectional geometric pairs plus heart, or spring cross-morph for any curated icon
Tones & fillstone sets the active fill and contrasting glyph (neutral, accent, status tones); fillAnimation picks scale, radial, or wipe
Shape & sizeshape 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.

Helps prioritize performance improvements.
Accept the terms to create an account.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Accept terms"Visible label and accessible name. State the choice in sentence case, e.g. "Email me product updates".
hideLabelbooleanDefault: falseHide the label visually when the context already names the field. It is still announced.
descriptionstring—Supporting text below the label, announced with the checkbox. Use it for consequences or details.
errorstring—Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely.
requiredbooleanDefault: falseMarks the checkbox as required for assistive technology and shows an indicator, e.g. for accepting terms. Your application validates it.
disabledbooleanDefault: falseUnavailable and removed from the tab order. A disabled checkbox is not submitted with a form.
namestring—Native form field name, submitted with the value in a form.
defaultCheckedboolean | 'indeterminate'Default: falseInitial 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.
valuestringDefault: "on"Value submitted with a form while the checkbox is checked. Defaults to "on", like a native checkbox.
checkedIconIconNameDefault: "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.
uncheckedIconIconName—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.
indeterminateIconIconNameDefault: "minus"Mark shown while indeterminate. The default minus shares points with the check, so the two morph into each other.
toneneutral | 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.
fillAnimationscale | 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).
shaperounded | circleDefault: "rounded"Box shape: rounded corners (the default) or a full circle.
sizesm | md | lgDefault: "md"Box of 16, 18 (Arc), or 20 pixels in a hit box one control tall.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeCheckboxTheme—Color mode, accent, and tokens, including boxSize and boxRadius. See Theming.
motionnone | subtle | expressiveDefault: "subtle"The fill animation, the mark drawing and morphing, and the press. none and system reduced-motion preferences make them immediate.
motionOptionsCheckboxMotionOptions—Fine-grained motion overrides: pressScale, and the fill and mark transitions (durations in ms).
dirltr | rtl—Reading direction; the box sits at the inline start. Omit it to inherit the page direction.

React integration

PropPurpose
checked, onCheckedChangeControl 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).
refRef to the native <input type="checkbox"> element.
idControl id; label, description, and error ids derive from it.
presetApplication defaults (such as size, tone, shape, theme), overridden by instance props.
tokensCSS custom properties (--ui-*) applied after the typed theme on the field root.
className, styleApplied to the outer field root, which carries the resolved --ui-* tokens.
Native attributesForwarded to <input> (autoFocus, form, onFocus, onBlur, aria-*, data-*, and others).

Keyboard & accessibility

KeyInteraction
TabMoves focus to or from the checkbox.
SpaceToggles 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: scale scales from 0.6 to 1, radial blooms a circle from 0 to 1.5, and wipe sweeps upward from scaleY(0) to 1, all on motionOptions.fill (Arc's snappy spring). 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's morph spring); geometric icon-morph pairs stay mounted across unchecked↔checked and swap cleanly only for indeterminate; custom icon pairs cross-morph with scale, slight rotation, and blur on motionOptions.mark.
  • Press & reduced motion: pressing scales only the box to motionOptions.pressScale (0.92) and springs back on release. Setting motion="none" or enabling prefers-reduced-motion: reduce makes 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": []
}

On this page