Skip to content

components/ChoiceCards

import { … } from 'zidane-ui'ui/src/components/ChoiceCards.tsx

Components#

ChoiceCardsComponent#

Renders a radio group of cards. The chosen card is raised, with an accent ring.

TypeScript
function ChoiceCards<T extends string>(props: ChoiceCardsProps<T>): Element
Type parameters
NameTypeDescription
Textends string
Parameters
NameTypeDescription
propsChoiceCardsProps<T>

Component props.

Element
ChoiceCards props
NameTypeDefaultDescription
ariaLabel?string

Accessible name of the radio group.

className?string

Extra classes on the group.

columns?1 | 2 | 3 | 43

Cards per row on wide screens. Narrow screens stack them.

numbered?boolean

Let the keys 1 to 9 pick the cards while the group has focus, and show the numbers while it has keyboard focus.

onChange(value: T) => void

Called with the value of the card picked by click or keyboard.

optionsreadonly ChoiceCardOption<T>[]

The cards, in order.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

valueT | undefined

The value of the chosen card. undefined: none is chosen yet.

ui/src/components/ChoiceCards.tsx:68

Interfaces#

ChoiceCardOptionInterface#

One card of a ChoiceCards group.

TypeScript
interface ChoiceCardOption<T extends string>
ChoiceCardOption type parameters
NameTypeDescription
Textends string
ChoiceCardOption properties
NameTypeDescription
badge?ReactNode

A short mark at the end of the title line, such as "recommended".

description?ReactNode

One or two lines under the title.

disabled?boolean

Grey the card out and skip it in keyboard navigation.

icon?string

Icon class (i-ph-*) before the title.

preview?ReactNode

Content above the title, such as a theme thumbnail or a small demo.

titleReactNode

The card's title.

valueT

The value reported to onChange when the card is picked. Unique among the options.

visual?ReactNode

A visual before the title, such as a BrandMark. Takes the place of icon.

ui/src/components/ChoiceCards.tsx:14

ChoiceCardsPropsInterface#

Props for ChoiceCards.

TypeScript
interface ChoiceCardsProps<T extends string>
ChoiceCardsProps type parameters
NameTypeDescription
Textends string
ChoiceCardsProps properties
NameTypeDefaultDescription
ariaLabel?string

Accessible name of the radio group.

className?string

Extra classes on the group.

columns?1 | 2 | 3 | 43

Cards per row on wide screens. Narrow screens stack them.

numbered?boolean

Let the keys 1 to 9 pick the cards while the group has focus, and show the numbers while it has keyboard focus.

onChange(value: T) => void

Called with the value of the card picked by click or keyboard.

optionsreadonly ChoiceCardOption<T>[]

The cards, in order.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

valueT | undefined

The value of the chosen card. undefined: none is chosen yet.

ui/src/components/ChoiceCards.tsx:41