RadioButtonCardGroup
Add some flair and professionalism to your radio buttons and associated content.
Note: The example below is slightly buggy due to a quirk in the docs, not due to a real issue with the component.
import { RadioButtonCardGroup, RadioButtonCardGroupItem } from "rfui-package";
Basic
<RadioButtonCardGroup name="basic-example">
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
Reacting to changes
<RadioButtonCardGroup
name="on-change-example"
onChange={(newValue) => {
console.log(newValue);
}}
>
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
With different value initially selected
By default the first value will be selected. This is in accordance with UX best practices. If you want a different value to be selected you can use
initialSelectedValue
.<RadioButtonCardGroup
name="initial-selected-value-example"
initialSelectedValue="two"
>
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
With no value initially selected
By default the first value will be selected. This is in accordance with UX best practices. If you don't want a value to be initially selected you can set
initialSelectedValue
to an empty string.<RadioButtonCardGroup
name="no-initial-selected-value-example"
initialSelectedValue=""
>
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
Padding
Set
padding
to "sm"
, "md"
, or "lg"
. Defaults to "md"
.<Stack className="gap-5">
<RadioButtonCardGroup name="padding-example-sm" padding="sm">
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
<RadioButtonCardGroup name="padding-example-md" padding="md">
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
<RadioButtonCardGroup name="padding-example-lg" padding="lg">
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
</Stack>
Rounded
Set
rounded
to "square"
, "sm"
, or "lg"
. Defaults to the value of the CSS variable --default-roundedness
. See "Default roundedness".<Stack className="gap-5">
<RadioButtonCardGroup name="rounded-example-square" rounded="square">
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
<RadioButtonCardGroup name="rounded-example-sm" rounded="sm">
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
<RadioButtonCardGroup name="rounded-example-lg" rounded="lg">
<RadioButtonCardGroupItem value="one">One</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="two">Two</RadioButtonCardGroupItem>
<RadioButtonCardGroupItem value="three">Three</RadioButtonCardGroupItem>
</RadioButtonCardGroup>
</Stack>
Props
Prop | Required | Default | Type and notes |
---|---|---|---|
name | ✔ | - |
|
initialSelectedValue | - | - |
|
padding | - | "md" |
|
rounded | - | - |
Defaults to the value of the CSS variable --default-roundedness . See "Default roundedness". |
onChange | - | - |
|
children | ✔ | - |
|
RadioButtonCardGroupItem
Prop | Required | Default | Type and notes |
---|---|---|---|
value | - | - |
|
children | ✔ | - |
|