import { Radio } from "@vortexlabs/vortex-native";
<Radio.Group
defaultValue="standard"
layout="default"
direction="vertical"
disabled={false}
>
<Radio.GroupLabel>Delivery method</Radio.GroupLabel>
<Radio.Item
size="md"
value="standard"
>
Standard
</Radio.Item>
<Radio.Item
size="md"
value="express"
>
Express
</Radio.Item>
</Radio.Group>Features
- Keeps one selected value per group.
- Supports disabled options and group errors.
- Arranges short options as horizontal cards.
Anatomy
<Radio.Group name="delivery">
<Radio.GroupLabel>Delivery method</Radio.GroupLabel>
<Radio.GroupDescription>Choose how the order ships.</Radio.GroupDescription>
<Radio.Item value="standard">Standard delivery</Radio.Item>
<Radio.Item value="express">Express delivery</Radio.Item>
</Radio.Group>Component Part
Description
Holds the selected value and supplies the group name to change callbacks.
Displays the heading for the options.
Adds text that applies to every option.
Selects one option, identified by its
value.Initial Value and Helper Text
Set defaultValue to choose the initial option. Use helperText on an item to explain that option.
<Radio.Group defaultValue="standard">
<Radio.GroupLabel>Delivery method</Radio.GroupLabel>
<Radio.GroupDescription>Delivery times start when the order ships.</Radio.GroupDescription>
<Radio.Item value="standard" helperText="Arrives in 3–5 days.">Standard</Radio.Item>
<Radio.Item value="express" helperText="Arrives the next day.">Express</Radio.Item>
</Radio.Group>Sizes
Use size on individual items in the default layout. A breakpoint object adjusts the size with the window width.
<Radio.Group ariaLabel="Notification frequency" defaultValue="daily">
<Radio.Item value="daily" size="md">Daily summary</Radio.Item>
<Radio.Item value="live" size={{ xs: "md", md: "lg" }}>As updates arrive</Radio.Item>
</Radio.Group>Cards and List Rows
Use horizontal cards for short options. List rows and cards use the medium control size.
<Stack gap={4}>
<Radio.Group layout="card" direction="horizontal" defaultValue="monthly">
<Radio.GroupLabel>Billing interval</Radio.GroupLabel>
<Radio.Item value="monthly" control={false}>Monthly</Radio.Item>
<Radio.Item value="yearly" control={false}>Yearly</Radio.Item>
</Radio.Group>
<Radio.Group layout="list" defaultValue="card">
<Radio.GroupLabel>Payment method</Radio.GroupLabel>
<Radio.Item value="card">Credit card</Radio.Item>
<Radio.Item value="invoice" disabled helperText="Available on the business plan.">Invoice</Radio.Item>
</Radio.Group>
</Stack>Group Validation
Set error on the group to mark every item and display errorText below the choices.
import { Radio } from "@vortexlabs/vortex-native";
import { useState } from "react";
export const BillingInterval = () => {
const [interval, setInterval] = useState<string | null>(null);
return (
<Radio.Group
value={interval}
error={interval === null}
errorText="Choose a billing interval."
onChange={({ value }) => setInterval(value)}
>
<Radio.GroupLabel>Billing interval</Radio.GroupLabel>
<Radio.Item value="month">Monthly</Radio.Item>
<Radio.Item value="year">Yearly</Radio.Item>
</Radio.Group>
);
};Controlled Selection
Pass value to Radio.Group and update it in onChange. Use null for an empty selection.
import { Radio, Stack, Text } from "@vortexlabs/vortex-native";
import { useState } from "react";
export const ReceiptMethod = () => {
const [method, setMethod] = useState<string | null>(null);
return (
<Stack gap={2}>
<Radio.Group value={method} onChange={({ value }) => setMethod(value)}>
<Radio.GroupLabel>Receive receipts by</Radio.GroupLabel>
<Radio.Item value="email">Email</Radio.Item>
<Radio.Item value="post">Post</Radio.Item>
</Radio.Group>
<Text>{method ? `Receipts will be sent by ${method}.` : "Choose a delivery method."}</Text>
</Stack>
);
};Read the selection from a descendant with useRadioGroup.
Accessibility
Description
Each item exposes the radio role and checked state. Pressing the selected radio keeps it selected.
Name each option with visible children or
ariaLabel. Use ariaLabel on the group for an explicit accessible name.