A Radio Button that enables extra emphasis and descriptive capability.
A set of RadioCards should be wrapped with a RadioCardGroup component to provide the correct HTML structure for our radio buttons. Any text within the card will be used as the label for the radio button, so ensure that you test this content and use aria-hidden to remove any unnecessary content from the announced text.
<RadioCardGroup defaultValue="alevel">
<RadioCard value="alevel">
<div className="flex flex-col gap-2">
<Text className="font-semibold">A-level</Text>
<Text size="sm" className="text-grey-700">Shows A-level grade projections.</Text>
</div>
</RadioCard>
<RadioCard value="ib">
<div className="flex flex-col gap-2">
<Text className="font-semibold">IB Diploma</Text>
<Text size="sm" className="text-grey-700">Shows IB grade projections.</Text>
</div>
</RadioCard>
</RadioCardGroup>
Props set on RadioCardGroup (appearance, theme, size, align and isFullWidth) are applied to every RadioCard that is a direct child of the group.
Appearance and theme
Like our inputs, RadioCard supports an appearance prop.
standard(default): white card with agrey-600border.modern: borderless card. Itsthemesets the background:grey(default,grey-100) for use on white surfaces, orwhitefor use on grey surfaces.
<div className="flex flex-col gap-6 rounded-md bg-white p-6">
<RadioCardGroup appearance="standard" defaultValue="1">
<RadioCard value="1">Standard</RadioCard>
<RadioCard value="2">Standard</RadioCard>
</RadioCardGroup>
<RadioCardGroup appearance="modern" theme="grey" defaultValue="1">
<RadioCard value="1">Modern grey</RadioCard>
<RadioCard value="2">Modern grey</RadioCard>
</RadioCardGroup>
<div className="bg-grey-100 p-4">
<RadioCardGroup appearance="modern" theme="white" defaultValue="1">
<RadioCard value="1">Modern white</RadioCard>
<RadioCard value="2">Modern white</RadioCard>
</RadioCardGroup>
</div>
</div>
Size
These are the available sizes for this component: md and lg. The default is md.
<div className="flex flex-col gap-6 rounded-md bg-white p-6">
<RadioCardGroup size="md" defaultValue="1">
<RadioCard value="1">Medium</RadioCard>
<RadioCard value="2">Medium</RadioCard>
</RadioCardGroup>
<RadioCardGroup size="lg" defaultValue="1">
<RadioCard value="1">Large</RadioCard>
<RadioCard value="2">Large</RadioCard>
</RadioCardGroup>
</div>
Alignment and width
Use align="right" to put the radio after the content, and isFullWidth to make each card fill its container.
<div className="flex flex-col gap-6 rounded-md bg-white p-6">
<RadioCardGroup align="left" defaultValue="1">
<RadioCard value="1">Radio on the left (default)</RadioCard>
<RadioCard value="2">Radio on the left (default)</RadioCard>
</RadioCardGroup>
<RadioCardGroup align="right" defaultValue="1">
<RadioCard value="1">Radio on the right</RadioCard>
<RadioCard value="2">Radio on the right</RadioCard>
</RadioCardGroup>
<RadioCardGroup align="right" isFullWidth defaultValue="1">
<RadioCard value="1">Full width, radio on the right</RadioCard>
<RadioCard value="2">Full width, radio on the right</RadioCard>
</RadioCardGroup>
</div>
States
Cards are unselected or selected, and can be disabled individually or as a group. Hover over a card, or move to a group with the Tab key, to see the hover and focus states.
<div className="flex flex-col gap-6 rounded-md bg-white p-6">
{['standard', 'modern'].map((appearance) => (
<div key={appearance} className="flex flex-col gap-3">
<Text size="sm" className="font-semibold">{appearance}</Text>
<RadioCardGroup appearance={appearance} defaultValue="selected">
<RadioCard value="default">Default</RadioCard>
<RadioCard value="selected">Selected</RadioCard>
</RadioCardGroup>
<RadioCardGroup appearance={appearance} defaultValue="selected" disabled>
<RadioCard value="disabled">Disabled</RadioCard>
<RadioCard value="selected">Disabled and selected</RadioCard>
</RadioCardGroup>
</div>
))}
</div>
Rich content
Any content can go inside a card. Keep it to a title and one short line of description, and set the size and layout on the group.
<div className="rounded-md bg-white p-6">
<RadioCardGroup appearance="modern" size="lg" isFullWidth defaultValue="trial">
<RadioCard value="trial">
<div className="flex flex-col gap-2">
<Text className="font-semibold">Start 5-day free trial</Text>
<Text size="sm" className="text-grey-700">Home practice and mock tests, cancel anytime.</Text>
</div>
</RadioCard>
<RadioCard value="pupil-premium">
<div className="flex flex-col gap-2">
<Text className="font-semibold">Check Pupil Premium eligibility</Text>
<Text size="sm" className="text-grey-700">Free premium access for eligible families.</Text>
</div>
</RadioCard>
</RadioCardGroup>
</div>