Skip to main content

RadioCardGroup

Library
Allium Design Systemweb-only
Repository
github.com/telus/allium-design-system
Package
npmjs.com/package/@telus-uds/ds-allium
Package version
1.14.0
Loading...

Introduction

import { RadioCardGroup } from '@telus-uds/ds-allium'

A RadioCardGroup renders a group of RadioCards, which display information with a title and separate content section like a card, but may be selected like a radio button.

Guidance

Use RadioCardGroup where the user needs to select one item from multiple options, and where those options need descriptive content beyond a simple single line of text. For example, for choosing between named options where additional content beyond the name is needed to make a choice.

Alternatives

  • If the options are fairly simple and can be described in a short phrase, consider Radio
  • If the options require additional information but it is supplementary or of interest to only a minority of users rather than essential information for a majority, consider Radio with a Tooltip
  • If the options are very simple and can be described in one or two words or numbers, consider ButtonGroup
  • If selecting an option simply navigates a user to a new page describing that option, rather than saving a selection in the current page or form, consider PreviewCard or StoryCard (web only)

Items

Use the items prop to pass an array of objects describing each RadioCard in the group:

  • title: main text passed to RadioCard's title prop
  • content: React content passed to RadioCard's children prop
  • id: identifier used to store which RadioCard is selected (uses title if undefinded)
  • onChange: optional function called on selection, in addition to updating the group's selection state
Loading...

Controlled

The selection state may be controlled by a parent by passing checkedId and an onChange function that updates the parent's state. If the component is controlled in this way, checkedId must never be undefined; pass null or an empty string if there is no selection.

Loading...

Uncontrolled

If checkedId is not provided, RadioCardGroup manages its own state. An initial selection may be provided by passing initialCheckedId.

Loading...

Use in forms

For web forms, the name prop may be used to define the name of the group's <fieldset> and input elements, and legend may be used to provide a title with <legend> type for the fieldset.

Loading...

Validation

Validation state may be set by passing 'error' or 'success' to the validation prop.

Loading...

A11y guidelines

RadioCardGroup accepts all the common accessibility props, but also sets accessibility role 'radiogroup' and controls the accessibility state of children like RadioCard and Feedback based on current state.

RadioCard component accepts all the common accessibility props, but also sets some defaults, including accessibility role 'radio' and accessibility state that depends on the other props (checked, inactive) or the internal state in case of uncontrolled RadioCard.

Platform considerations

The component is available on both native platforms and web.

Props

NameTypeDefaultDescription
checkedIdstringIf not undefined, the radio card with this id is selected (or none is selected if 'null'), and the element's selection state will be controlled by its parent using the 'onChange' function.
copy'en' | 'fr''en'Whether the English or French copy will be used (e.g. for accessibility labels).
feedbackstringIf provided, a Feedback element is rendered containing this text.
hintstringOptional additional text giving more detail to help a user make a choice.
inactiveboolIf true, the radio card cannot be interacted with, elements are set as 'disabled' and if the theme supports 'inactive' appearances rules, these are applied.
initialCheckedIdstringIf provided, the radio card with this id is selected on first render.
itemsArray<{ title, content, id, onChange }>[]Array of objects containing specifics for each RadioCard to be rendered in the group.
legendstringMain text used to describe this group, used in Fieldset's Legend element.
namestringOn Web, this is passed to the 'name' attribute of the fieldset and each radio input.
onChangefuncFunction to call on change in selection state. Is required if the selection state is controlled by a parent using checkedId and the input is not readOnly.
radioCardTokenscustomOptional theme token overrides for each inner RadioCard component
readOnlyboolIf true, the radio cards cannot be selected by the user and simply show their current state.
tokenscustomSystem tokens prop, see tokens for more details
tooltipstringOptional tooltip text content to include alongside the legend and hint.
validation'error' | 'success'Current validation status of the group, passed to the feedback element if there is one.
variantobjectOfSystem variant prop, see variants for more details

Tokens

In exceptional circumstances, the following tokens can be passed to this component to override its default styles. Do not do this unless absolutely necessary. Read more about overriding styles.

View Tokens
Prop NameToken PropertyToken Type
tokensdirectiondirection
spaceinteger
fieldSpaceinteger
radioCardTokensouterBorderColorcolor
outerBorderWidthborder
outerBorderGapsize
flexinteger
backgroundColorcolor
borderColorcolor
borderRadiusradius
borderWidthborder
paddingBottomsize
paddingLeftsize
paddingRightsize
paddingTopsize
minWidthsize
shadowshadow
radioCheckedBackgroundColorcolor
radioCheckedSizesize
radioInputBackgroundColorcolor
radioInputBorderColorcolor
radioInputBorderWidthborder
radioInputOutlineColorcolor
radioInputOutlineWidthborder
radioInputSizesize
radioOuterBorderColorcolor
radioOuterBorderWidthborder
radioOuterBorderGapsize
fontSizefontSize
fontNamefontName
lineHeightlineHeight
colorcolor
letterSpacingletterSpacing
textTransformtextTransform
fontWeightfontWeight
radioSpaceinteger
contentSpaceinteger

Figma

Variants

This component does not have any stylistic variants.

Feedback

```