RadioCard
RadioCard
is a component used for allowing users to select one option from multiple choices.
<RadioCardGroup.Root>
<RadioCardGroup.Item.Root value="1">
<RadioCardGroup.Item.Label>ビアンカ</RadioCardGroup.Item.Label>
<RadioCardGroup.Item.Description>
パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。
</RadioCardGroup.Item.Description>
</RadioCardGroup.Item.Root>
<RadioCardGroup.Item.Root value="2">
<RadioCardGroup.Item.Label>フローラ</RadioCardGroup.Item.Label>
<RadioCardGroup.Item.Description>
大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。
</RadioCardGroup.Item.Description>
</RadioCardGroup.Item.Root>
<RadioCardGroup.Item.Root value="3">
<RadioCardGroup.Item.Label>ルドマン</RadioCardGroup.Item.Label>
<RadioCardGroup.Item.Description>
なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。
</RadioCardGroup.Item.Description>
</RadioCardGroup.Item.Root>
</RadioCardGroup.Root>
Usage
import { RadioCard, RadioCardGroup } from "@yamada-ui/react"
import { RadioCard, RadioCardGroup } from "@/components/ui"
import { RadioCard, RadioCardGroup } from "@workspaces/ui"
<RadioCardGroup.Root>
<RadioCardGroup.Item.Root>
<RadioCardGroup.Item.Label />
<RadioCardGroup.Item.Description />
<RadioCardGroup.Item.Addon />
</RadioCardGroup.Item.Root>
</RadioCardGroup.Root>
Using items
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return <RadioCardGroup.Root items={items} />
Change Variant
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{ label: "Checked", value: "1" },
{ label: "Unchecked", value: "2" },
],
[],
)
return (
<VStack>
<For each={["subtle", "surface", "outline"]}>
{(variant) => (
<RadioCardGroup.Root
key={variant}
variant={variant}
defaultValue="1"
items={items}
/>
)}
</For>
</VStack>
)
Change Size
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{ label: "Checked", value: "1" },
{ label: "Unchecked", value: "2" },
],
[],
)
return (
<VStack>
<For each={["sm", "md", "lg"]}>
{(size) => (
<RadioCardGroup.Root
key={size}
size={size}
defaultValue="1"
items={items}
/>
)}
</For>
</VStack>
)
Change Color Scheme
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{ label: "Checked", value: "1" },
{ label: "Unchecked", value: "2" },
],
[],
)
return (
<VStack>
<For each={["success", "warning"]}>
{(colorScheme) => (
<RadioCardGroup.Root
key={colorScheme}
colorScheme={colorScheme}
defaultValue="1"
items={items}
/>
)}
</For>
</VStack>
)
Set Default Value
To set a default value, set a value to defaultValue
.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return <RadioCardGroup.Root defaultValue="2" items={items} />
Change Orientation
To change the orientation, set orientation
to "horizontal"
or "vertical"
. By default, "horizontal"
is set.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return <RadioCardGroup.Root items={items} orientation="vertical" />
Change Shape
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return (
<VStack>
<For each={["circle", "square", "rounded"]}>
{(shape) => (
<RadioCardGroup.Root
key={shape}
shape={shape}
defaultValue="2"
items={items}
/>
)}
</For>
</VStack>
)
Change Alignment
To change the alignment, set justify
to "start"
, "center"
, or "end"
. By default, "start"
is set.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return (
<VStack>
<For each={["start", "end"]}>
{(justify) => (
<RadioCardGroup.Root
key={justify}
justify={justify}
defaultValue="2"
items={items}
/>
)}
</For>
</VStack>
)
Add Addon
To add an addon, set ReactNode
to addon
.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
addon: "ドラゴンクエストV 天空の花嫁",
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
addon: "ドラゴンクエストV 天空の花嫁",
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
addon: "ドラゴンクエストV 天空の花嫁",
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return <RadioCardGroup.Root items={items} orientation="vertical" />
Hide Indicator
To hide the indicator, set withIndicator
to false
.
<RadioCardGroup.Root withIndicator={false}>
<RadioCardGroup.Item.Root flexDirection="row" gap="sm" value="1" w="auto">
<RabbitIcon fontSize="2xl" />
<Text as="span">ウサギ</Text>
</RadioCardGroup.Item.Root>
<RadioCardGroup.Item.Root flexDirection="row" gap="sm" value="2" w="auto">
<SnailIcon fontSize="2xl" />
<Text as="span">カタツムリ</Text>
</RadioCardGroup.Item.Root>
<RadioCardGroup.Item.Root flexDirection="row" gap="sm" value="3" w="auto">
<SquirrelIcon fontSize="2xl" />
<Text as="span">リス</Text>
</RadioCardGroup.Item.Root>
</RadioCardGroup.Root>
Disable
To disable, set disabled
to true
.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return (
<VStack>
<For each={["subtle", "surface", "outline"]}>
{(variant) => (
<RadioCardGroup.Root
key={variant}
variant={variant}
defaultValue="2"
disabled
items={items}
/>
)}
</For>
<Field.Root disabled label="Who is your favorite character?">
<RadioCardGroup.Root defaultValue="2" items={items} />
</Field.Root>
</VStack>
)
Read-Only
To make read-only, set readOnly
to true
.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return (
<VStack>
<For each={["subtle", "surface", "outline"]}>
{(variant) => (
<RadioCardGroup.Root
key={variant}
variant={variant}
defaultValue="2"
readOnly
items={items}
/>
)}
</For>
<Field.Root label="Who is your favorite character?" readOnly>
<RadioCardGroup.Root defaultValue="2" items={items} />
</Field.Root>
</VStack>
)
Invalid
To make invalid, set invalid
to true
.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return (
<VStack>
<For each={["subtle", "surface", "outline"]}>
{(variant) => (
<RadioCardGroup.Root
key={variant}
variant={variant}
defaultValue="2"
invalid
items={items}
/>
)}
</For>
<Field.Root invalid label="Who is your favorite character?">
<RadioCardGroup.Root defaultValue="2" items={items} />
</Field.Root>
</VStack>
)
Customize Border Color
To customize the border color, set a color to focusBorderColor
or errorBorderColor
.
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return (
<VStack>
<RadioCardGroup.Root focusBorderColor="green.500" items={items} />
<RadioCardGroup.Root
defaultValue="2"
errorBorderColor="orange.500"
invalid
items={items}
/>
</VStack>
)
Control
const [value, setValue] = useState("2")
const items = useMemo<RadioCardGroup.RootProps["items"]>(
() => [
{
description:
"パパスの息子より、ふたつ年上のしっかり者の幼なじみ。彼と一緒に、レヌール城のお化け退治に繰り出した。",
label: "ビアンカ",
value: "1",
},
{
description:
"大富豪ルドマンの娘で、デボラの妹。ちょっぴり天然なところもある、清楚で可憐なお嬢様。",
label: "フローラ",
value: "2",
},
{
description:
"なんと、この私が、好きと申すか!?そ、それはいかん!もう1度、考えてみなさい。",
label: "ルドマン",
value: "3",
},
],
[],
)
return <RadioCardGroup.Root items={items} value={value} onChange={setValue} />
"use client"
to the top of the file.Props
Accessibility
Currently, this section is being updated due to the migration of v2.