Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.14 KB

checkbox.md

File metadata and controls

35 lines (24 loc) · 1.14 KB

Checkbox

Includes or excludes one item, saved with a form.

Example

import { Checkbox, Field } from "@usememos/ui";

<Field.Root>
  <Field.Label>
    <Checkbox checked={digest} onCheckedChange={setDigest} /> Weekly digest
  </Field.Label>
</Field.Root>

Props

interface CheckboxProps extends BaseCheckbox.Root.Props {
  size?: Size; // box: 14, 16, 18px
}

Wraps Base UI's Checkbox root with its indicator built in: checked, defaultChecked, onCheckedChange, indeterminate, disabled, name, value pass through. Renders a <span role="checkbox"> and a hidden <input> for forms.

Rules

  • Name it with a Field.Label around it, or aria-label.
  • For a setting that applies at once, use Switch. For a labeled group, wrap the boxes in a Fieldset.

Style

  • Unchecked: an empty well with an edge. Checked: a flat primary square with a contrasting mark.
  • Lucide Check at a 2px stroke; Minus when indeterminate. The mark changes immediately with the state, without a delayed fade or scale animation. The control does not resize while pressed.