A labeled group of radios for one choice, or checkboxes for several with multiple. The ref reaches the inputs: a callback ref gets each one, an object ref the first.
A Markdown brief for Claude, Cursor or v0: install, setup, props and a complete example.
For two to six options that should all be visible: radios for one, checkboxes for several.
An on/off setting that applies at once? Switch. A lone yes or no sent with a form? Checkbox.
Native radios and checkboxes in a fieldset whose legend is the label, so the group is announced with each option.
import { Choice } from '@idyeah/diya'Stable since 1.0.0
labelRequiredstringVisible group label (the fieldset legend); also names the group for assistive tech. Hide it with hideLabel.
optionsRequiredChoiceOption[]The choices, in display order.
disabledbooleanDisables every option in the group.
Default false
errorstringVisible error message below the options; marks the group invalid while set.
helperTextstringVisible hint below the options, announced with the group; error replaces it while set.
hideLabelbooleanHides the group label visually but keeps it as the group's accessible name.
Default false
multiplebooleanSingle mode (the default): radios, leave unset or false. Multiple mode: checkboxes, any number chosen.
namestringForm field name shared by the inputs; defaults to a generated id.
onBlurFocusEventHandler<HTMLInputElement>Called when one of the inputs loses focus.
onChangeChangeEventHandler<HTMLInputElement>Native change event from the radio or checkbox that changed, as react-hook-form's register() expects; onValueChange still fires.
requiredbooleanAsks the browser to require a choice before the form submits; radios only.
size"small" | "medium" | "large"Control and type size; defaults to 'medium'.
Default 'medium'
multiple={false} (the default)defaultValuestringThe initially chosen value when uncontrolled; a form reset returns to it.
onValueChange(value: string) => voidCalled with the chosen option's value.
valuestringThe chosen option's value, or '' for none, when controlled; pair it with onValueChange.
multiple={true}defaultValuestring[]The initially chosen values when uncontrolled; a form reset returns to them.
onValueChange(value: string[]) => voidCalled with the full new array of chosen values.
selectAllbooleanAdds a visible "Select all" checkbox first that toggles every enabled option and shows a mixed state when some are chosen.
valuestring[]The chosen options' values, when controlled; pair it with onValueChange.
Also takes every native <fieldset> attribute, such as id, aria-* or data-*.