RadioGroup displays field guidance information along with the selection state. You can use label, labelWeight, indicator, showRequiredIndicator, description, errorMessage.
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";export function ContactMethod() { return ( <RadioGroup label="Preferred contact method" indicator="Required" description="Please select how you would like to be contacted." defaultValue="chat" > <RadioGroupItem value="chat" label="Chat" /> <RadioGroupItem value="phone" label="Phone" /> </RadioGroup> );}
If invalid is true and errorMessage exists, the error message is displayed instead of description on screen.
RadioGroup is an accessibility element by default and uses accessibility-role-description="radiogroup". If the group is disabled, it also passes accessibility-traits="disabled". If you pass a string label to Registry RadioGroup, the same content is also connected to accessibility-label.
RadioGroupItem uses accessibility-role-description="radio" by default. The selection state is passed as selected or not selected in accessibility-value, and the disabled state is passed as accessibility-traits="disabled".
If you use a string label, the Registry wrapper connects that value to the item's accessibility-label. When you put non-string content in label or compose the compound API directly, explicitly specify accessibility-label for each item. If needed, you can override all default accessibility props directly.
Unlike React's per-item weight, Lynx's weight is a group-level prop. The example below divides groups by weight. The two groups share the same control value, so only one of the two items can be selected.
Lynx's size is also a group-level prop. The example below divides groups by size. The two groups share the same control value, so only one of the two items can be selected.
Loading Lynx example…
Preparing URL…
import "./styles";import { useState } from "@lynx-js/react";import { VStack, useSeedClassName } from "@seed-design/lynx-react";import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";const longLabel = "Consequat ut veniam aliqua deserunt occaecat enim occaecat veniam et et cillum nulla officia incididunt incididunt. Sint laboris labore occaecat fugiat culpa voluptate ullamco in elit dolore exercitation nulla.";export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [value, setValue] = useState("medium"); return ( <view className={`${seedClassName} docs-lynx-radio-group-root`}> <VStack className="radio-group-preview"> <RadioGroup accessibility-label="Long label options" value={value} size="medium" tone="neutral" onValueChange={setValue} > <RadioGroupItem value="medium" label={longLabel} /> </RadioGroup> <RadioGroup accessibility-label="Long label options" value={value} size="large" tone="neutral" onValueChange={setValue} > <RadioGroupItem value="large" label={longLabel} /> </RadioGroup> </VStack> </view> );}
React Hook Form assumes HTML forms and input, so the same example cannot be executed on Lynx. On Lynx, control the selection value with value and onValueChange. Handle submission and validation in app state management and request flow.
Using Registry's Radiomark and the compound API of @seed-design/lynx-react together, you can share the selection state while changing the item layout. Radiomark can only be used inside RadioGroup.Item.
Lynx RadioGroupItem changes the background color of Radiomark while being pressed. Since it does not reduce size like React, the --seed-radiomark-feedback-scale CSS variable is also not used.
Lynx RadioGroup has the following differences from React RadioGroup.
Error message rendering: React keeps description in the accessibility tree when error is displayed, but Lynx has no visually hidden handling method in the DOM, so it renders only errorMessage and excludes description from screen and accessibility tree.
Icon rendering method: The default RadioGroup.ItemIndicator renders as a <view> dot. To pass custom icons, install @karrotmarket/lynx-monochrome-icon separately and use monochrome icon components. Direct <svg> injection is not supported in Lynx.
Event handling: Exposes only onValueChange(value: string) instead of onChange. Tap handlers are owned inside the item.
Pressed state: Instead of size reduction on the web, internal press state changes the background color of Radiomark.
Rendering elements: Renders native <view> / <text> elements instead of HTML <label> / <input type="radio">.
Strict containment: RadioGroupItem, Radiomark, RadioGroup.ItemControl, RadioGroup.ItemIndicator, RadioGroup.ItemLabel must be used within the appropriate context of RadioGroup.Root and RadioGroup.Item. Radiomark is not a standalone primitive but a snippet helper that wraps ItemControl and ItemIndicator within item context.
Custom icon packages are not included in the Registry default installation.
bun add @karrotmarket/lynx-monochrome-icon@^1.20.0