Components / Foundations
ChoiceBase
A native checkbox or radio, visually hidden under a Cynosure skin but still focusable, clickable and form-associated. It is a foundation: it has no visual opinions, and the composite that uses it draws the visible control.
Who uses itLink to "Who uses it"
Checkbox, Switch, RadioGroup and SegmentedControl.
When to use it directlyLink to "When to use it directly"
Only when building a new choice-style composite (a custom checkbox, radio or toggle look) that must behave like a real form control.
Use a component instead when you need a labelled control: Checkbox or Switch for on/off, RadioGroup for one of several, SegmentedControl for a compact choice.
UsageLink to "Usage"
import { ChoiceBase } from "@arshad-shah/cynosure";
<ChoiceBase type="checkbox" name="terms" value="yes" indeterminate={partial} />
<ChoiceBase type="radio" name="size" value="md" />PropsLink to "Props"
It accepts every native input attribute except type, which is required and must be "checkbox" or "radio".
| Prop | What it does | Type | Default |
|---|---|---|---|
typeRequired | Which native control to render. | "checkbox" | "radio" | |
indeterminate | Checkbox only: the mixed state (aria-checked="mixed"). | boolean |
Generated from the type definitions in @arshad-shah/cynosure 0.5.0.
GuaranteesLink to "Guarantees"
- It stays focusable, clickable and form-associated (FormData, reset, required) without extra code.
indeterminatesets the mixed state on the underlying input. It applies to checkboxes only.- The ref reaches the native
<input>. - It adds the
cy-choice-baseclass (its stylesheet isstyles/choice-base.css), which hides it visually; anyclassNameyou pass is kept alongside.
RelatedLink to "Related"
These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.