RadioCard
API Reference
Prop | Type | Default | Description |
|---|---|---|---|
value | string | ||
title | string | ||
autoFocus | boolean | false | |
bg | string | ||
children | React.ReactNode | ||
data-test | string | ||
description | string | ||
disabled | boolean | false | |
hint | React.ReactNode | ||
image | string | ||
noControl | boolean | false | |
onClick | React.MouseEventHandler<Element> |
Examples
With control
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup name="group-with-radio" value={choice} onChange={(e) => setChoice(e.target.value)} isValid={isValid}> <RadioCard value="value-disabled" title="Yes" /> <RadioCard value="value-simple" title="No" /> </RadioGroup> ) }
With description
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup name="group-with-radio" value={choice} onChange={(e) => setChoice(e.target.value)} isValid={isValid}> <RadioCard value="value-description1" title="Lorem ipsum" description="A disabled radio card" /> <RadioCard value="value-description2" title="Lorem ipsum" description="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore." /> </RadioGroup> ) }
With children (can be any element)
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup name="radio-card-select-input" value={choice} onChange={(e) => setChoice(e.target.value)} isValid={isValid}> <RadioCard value="radio-card-select-input1" title="Lorem ipsum" /> <RadioCard value="radio-card-select-input2" title="Lorem ipsum"> <SelectInput name="brand" label="Brand"> <option value="" /> <option value="mercedes">Mercedes</option> <option value="volvo">Volvo</option> <option value="audi">Audi</option> <option value="skoda">Skoda</option> </SelectInput> </RadioCard> </RadioGroup> ) }
Without control
Looking like SmallCard
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup name="group-without-radio" value={choice} onChange={(e) => setChoice(e.target.value)} isValid={isValid}> <RadioCard value="value-no-control-and-hint" title="Lorem ipsum" noControl /> <RadioCard value="value-no-control" title="Lorem ipsum" noControl /> </RadioGroup> ) }
Without control - with description
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup name="group-without-radio" value={choice} onChange={(e) => setChoice(e.target.value)} isValid={isValid}> <RadioCard value="value-no-control-and-hint-with-description1" description="Text becomes left aligned with description instead of centered" title="Lorem ipsum" noControl /> <RadioCard value="value-no-control-with-description2" description="Text becomes left aligned with description instead of centered" title="Lorem ipsum" noControl /> </RadioGroup> ) }
Without control and with image
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup name="group-without-radio-with-image" value={choice} onChange={(e) => setChoice(e.target.value)} description={choice ? `Your choice is: ${choice}` : ''} errorMessage={!isValid && 'Please select something.'} isValid={isValid}> <RadioCard value="value-no-control-image-and-hint" image="/images/components/radioCard/santander.svg" title="Lorem ipsum" description="Radio card with an image and provided hint" noControl /> <RadioCard value="value-no-control-image-only" image="/images/components/radioCard/black_car.png" title="Lorem ipsum" description="Radio card without hint and with image" noControl /> </RadioGroup> ) }
Horizontal
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup direction="row" name="group-with-only-title-horizontal" value={choice} onChange={(e) => setChoice(e.target.value)} isValid={isValid}> <RadioCard value="horizontal-title1" title="Lorem ipsum" noControl /> <RadioCard value="horizontal-title2" title="Lorem ipsum" noControl /> <RadioCard value="horizontal-title3" title="Lorem ipsum" noControl /> <RadioCard value="horizontal-title4" title="Lorem ipsum" noControl /> </RadioGroup> ) }
Horizontal - take up all the space
function Example() { const [choice, setChoice] = React.useState() const isValid = choice !== undefined return ( <RadioGroup name="group-with-only-title-horizontal" value={choice} onChange={(e) => setChoice(e.target.value)} isValid={isValid}> <Grid columns="repeat(4, 1fr)" gap={2}> <RadioCard value="horizontal-full-title1" title="Lorem ipsum" noControl /> <RadioCard value="horizontal-full-title2" title="Lorem ipsum" noControl /> <RadioCard value="horizontal-full-title3" title="Lorem ipsum" noControl /> <RadioCard value="horizontal-full-title4" title="Lorem ipsum" noControl /> </Grid> </RadioGroup> ) }