RadioGroup
A native group of exclusive choices with a shared highlight.
Installation
Import from the Reflow workspace package.
Playground
Open demoimport { RadioGroup } from '@rtzll/reflow'
import { type Handle } from 'remix/component'
export function Example(handle: Handle) {
const options = [{"label":"Option A","value":"0"},{"label":"Option B","value":"1"},{"label":"Option C","value":"2"}]
return () => (
<>
<RadioGroup label="Options" hideLabel defaultValue="0" options={options} />
</>
)
}With descriptions
import { RadioGroup } from '@rtzll/reflow'
import { type Handle } from 'remix/component'
export function Example(handle: Handle) {
const options = ['Apple', 'Banana', 'Cherry', 'Mango'].map((label) => ({ value: label.toLowerCase(), label }))
return () => (
<>
<RadioGroup label="Plan" options={[
{ value: 'free', label: 'Free', description: 'For personal projects' },
{ value: 'pro', label: 'Pro', description: 'For growing teams' },
]} defaultValue="free" />
</>
)
}Horizontal
import { RadioGroup } from '@rtzll/reflow'
import { type Handle } from 'remix/component'
export function Example(handle: Handle) {
const options = ['Apple', 'Banana', 'Cherry', 'Mango'].map((label) => ({ value: label.toLowerCase(), label }))
return () => (
<>
<RadioGroup label="Size" orientation="horizontal" options={options} />
</>
)
}API Reference
Public props for the Reflow implementation. Native controls also accept their standard HTML attributes and Remix event mixes.
RadioGroup
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Current value when controlled by the parent. |
defaultValue | string | — | Initial value for an uncontrolled component. |
required | boolean | — | Requires a value when submitting the form. |
onValueChange | ((value: string) => void) | — | Called when the selected value changes. |
options* | readonly GroupOption[] | — | Choices available to the user. |
label* | string | — | Accessible name or visible label for the control. |
hideLabel | boolean | — | Keeps the label available to assistive technology while hiding it visually. |
name | string | — | Name used when the control participates in a form. |
disabled | boolean | — | Prevents interaction and conveys the disabled state. |
orientation | "horizontal" | "vertical" | vertical | Layout direction. |
GroupOption
| Prop | Type | Default | Description |
|---|---|---|---|
value* | string | — | Value submitted for this option. |
label* | RemixNode | — | Visible option label. |
description | RemixNode | — | Additional explanatory text. |
disabled | boolean | — | Prevents interaction and conveys the disabled state. |