GitHub

Checkbox

Toggle control for boolean selection

Installation

pnpm add @corew500/ui

Usage

import { Checkbox } from "@corew500/ui/checkbox"

<Checkbox>Content</Checkbox>

Variants

checkboxVariants

AxisValuesDefault
size
smdefaultlg
default

checkboxIndicatorVariants

AxisValuesDefault
size
smdefaultlg
default

CMS Integration

CMSPayload CMS Integration
This component supports CMS-driven content via @corew500/cms-payload.
Loading...

API Reference

Props

PropTypeDefaultDescription
sizeenum"default"Size variant for the checkbox.
classNameenum—CSS class applied to the element, or a function that returns a class based on the component’s state.
defaultCheckedenumfalseWhether the checkbox is initially ticked. To render a controlled checkbox, use the `checked` prop instead.
styleenum—Style applied to the element, or a function that returns a style object based on the component’s state.
idstring—The id of the input element.
valuestring—The value of the selected checkbox.
renderenum—Allows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
namestringundefinedIdentifies the field when a form is submitted.
checkedenumundefinedWhether the checkbox is currently ticked. To render an uncontrolled checkbox, use the `defaultChecked` prop instead.
disabledenumfalseWhether the component should ignore user interaction.
onCheckedChange(checked: boolean, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element; }) => void—Event handler called when the checkbox is ticked or unticked.
readOnlyenumfalseWhether the user should be unable to tick or untick the checkbox.
requiredenumfalseWhether the user must tick the checkbox before submitting a form.
indeterminateenumfalseWhether the checkbox is in a mixed state: neither ticked, nor unticked.
inputRefenum—A ref to access the hidden `<input>` element.
parentenumfalseWhether the checkbox controls a group of child checkboxes. Must be used in a [Checkbox Group](https://base-ui.com/react/components/checkbox-group).
uncheckedValuestring—The value submitted with the form when the checkbox is unchecked. By default, unchecked checkboxes do not submit any value, matching native checkbox behavior.
nativeButtonenumfalseWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button.

Accessibility

Keyboard Navigation

  • Supports keyboard activation (Space to toggle)
  • Focus ring visible for keyboard navigation

Screen Readers

  • Checked state announced by screen readers
  • Use `aria-labelledby` pointing to the label's `id`, or `aria-label` when no visible label exists

Additional

  • - Uses native checkbox semantics via Base UI primitive
  • Note: `htmlFor`/`id` does not work with Base UI Checkbox (id goes to hidden input, not the visible element)

Localization

Translatable Content

  • - Checkbox has no text content; localize the associated Label

Related