FORMS
RadioGroup
Native radios in a fieldset, with hints per option. The quiet alternative to ChoiceGroup's cards.
PREVIEW
SOURCE
import { RadioGroup } from '@objectifthunes/whiteboard'
<RadioGroup
label="Billing period"
value={period}
onChange={setPeriod}
options={[
{ value: 'monthly', label: 'Monthly', hint: 'Cancel any time.' },
{ value: 'yearly', label: 'Yearly', hint: 'Two months free, billed up front.' },
{ value: 'invoice', label: 'By invoice', hint: 'Annual only.', disabled: true },
]}
error={submitted && !period ? 'Pick a billing period.' : undefined}
/>
<RadioGroup label="Visibility" direction="row" value={v} onChange={setV} options={SHORT} />NOTES
Native radios inside a real fieldset with a legend, so the group caption is announced with each option rather than being a floating label. Arrow-key behaviour comes free from the browser.
ChoiceGroup covers the same job with big clickable cards, which suits an onboarding step or a plan picker. Use RadioGroup when the choice is one line in a longer form and cards would shout.
The hintper option is where the trade-off goes. A radio labelled "Yearly" with no explanation of what you give up is a choice people postpone.
direction="row" is for two or three short labels only. Once hints are involved, a row becomes unreadable.