Detent web components
By Shane Logsdon

Forms & inputs

Checkbox

Implemented

Checkmark draws itself, then settles

detent-checkbox

Port status
Catalog status
implemented
Origin
upstream
Phase
3
Wave
phase-3-forms
Group
Forms & inputs
I accept the terms

4.3 KB gzip for the class module

Variants

Weekly digest
Partially selected
Managed by your admin

Recorded states

  • disabled recorded state; no setter
  • checked recorded state; no setter
  • indeterminate recorded state; no setter

Usage

Import

import '/components/checkbox/define.js';

// or register it yourself
import { DetentCheckbox } from '/components/checkbox/checkbox.js';

Attributes

  • checked
  • default-checked
  • description
  • disabled
  • indeterminate
  • name
  • required
  • value

Properties

  • checked
  • defaultChecked
  • indeterminate
  • disabled
  • required
  • name
  • value
  • description

Slots

  • label

Events

No events are recorded for this component.

Example

Runnable example: site/examples/checkbox.ts. The snippet below is generated from the catalogued attributes.

<detent-checkbox
  checked
  default-checked
  description
  disabled
  indeterminate
  name
  required
  value
></detent-checkbox>

Source

The pinned upstream source for this row:

  • src/components/ui/DrawCheckbox.tsx sha256 e4e2fa02733c…

Native files

The native module and its artifacts:

  • src/components/checkbox/checkbox.ts
  • src/components/checkbox/styles.css
  • src/components/checkbox/define.ts
  • docs/components/checkbox.md
  • site/examples/checkbox.ts
  • tests/browser/checkbox.spec.ts
  • evidence/components/checkbox.md

API

Boolean attributes follow HTML presence semantics: present means true, absent means false, and disabled="false" still means disabled.

Attributes

Attributes
AttributePropertyTypeDefaultNotes
checkedcheckedbooleanundefinedPresence semantics: present means true, absent means false.
default-checkeddefaultCheckedbooleanfalsePresence semantics: present means true, absent means false.
descriptiondescriptionstringundefinedKebab-case attribute; camelCase property.
disableddisabledbooleanfalsePresence semantics: present means true, absent means false.
indeterminateindeterminatebooleanfalsePresence semantics: present means true, absent means false.
name———Recorded in the catalog as an attribute.
required———Recorded in the catalog as an attribute.
value———Recorded in the catalog as an attribute.

Properties

Properties
PropertyTypeDefaultNotes
checkedbooleanundefinedProperty-only: assign from script; not accepted as an attribute.
defaultCheckedbooleanfalseProperty-only: assign from script; not accepted as an attribute.
indeterminatebooleanfalseProperty-only: assign from script; not accepted as an attribute.
disabledbooleanfalseProperty-only: assign from script; not accepted as an attribute.
required——Recorded in the catalog without a top-level type; pinned from source when the row is ported.
name——Recorded in the catalog without a top-level type; pinned from source when the row is ported.
value——Recorded in the catalog without a top-level type; pinned from source when the row is ported.
descriptionstringundefinedProperty-only: assign from script; not accepted as an attribute.

Events

No custom events are recorded for this component.

Slots

Slots
SlotNotes
labelConsumer content; rendered through a slot, never re-created.

CSS customisation

  • React `children`/`ReactNode` props become DOM slots; caller content stays light DOM.
  • Framer Motion springs/AnimatePresence ported to CSS transitions, WAAPI or the shared rAF spring helper.
  • React state/hooks replaced by element-owned state with pre-upgrade property preservation.
  • Native additions: name, value (default "on"), required, setFormValue/setValidity, checkValidity/reportValidity, reset/restore, fieldset detection, and one composed change dispatch.
  • A hidden input plus click-forwarding div became a same-tree `<label>` proxy so activation is native (PC-12.1).
  • `indeterminate` is presentation only and submits nothing; it is cleared by user activation.
  • Disabled no longer fades the text (upstream opacity-30 measured 1.9:1 on the description).
  • Motion is CSS with two faithful keyframes: 280ms path draw cubic-bezier(0.65,0,0.35,1) and 320ms box pop 0.9 to 1.04 to 1; the indeterminate bar's springSnappy became a 240ms CSS animation (PC-10.4).
  • Token and color-mix palette; light and dark are both real.

What it does

A checkbox that draws its checkmark, supports a mixed state and submits with a form like a native checkbox.

Upstream behaviour
  • Checkmark animates via stroke-dashoffset (path length 0 -> 1) with a snappy draw curve
  • Box scales 0.9 -> 1.04 -> 1.0 for a tiny physical overshoot, then settles
  • Indeterminate state draws a bar from left to right via scaleX origin
  • Accent background swaps to var(--accent) when checked — theme aware
  • Full controlled / uncontrolled state support, plus ref forwarding
Differences from upstream
  • React `children`/`ReactNode` props become DOM slots; caller content stays light DOM.
  • Framer Motion springs/AnimatePresence ported to CSS transitions, WAAPI or the shared rAF spring helper.
  • React state/hooks replaced by element-owned state with pre-upgrade property preservation.
  • Native additions: name, value (default "on"), required, setFormValue/setValidity, checkValidity/reportValidity, reset/restore, fieldset detection, and one composed change dispatch.
  • A hidden input plus click-forwarding div became a same-tree `<label>` proxy so activation is native (PC-12.1).
  • `indeterminate` is presentation only and submits nothing; it is cleared by user activation.
  • Disabled no longer fades the text (upstream opacity-30 measured 1.9:1 on the description).
  • Motion is CSS with two faithful keyframes: 280ms path draw cubic-bezier(0.65,0,0.35,1) and 320ms box pop 0.9 to 1.04 to 1; the indeterminate bar's springSnappy became a 240ms CSS animation (PC-10.4).
  • Token and color-mix palette; light and dark are both real.
Previous: Drag to Confirm Next: Status Island

Docs

Components

Project