Skip to Content
CodeUI

RadioList

@codeui/solid v0.3.0

A list of radio buttons for choosing one option.

When to use

Choose one named value from a visible list of export options.

When to choose another component

Use SegmentedControl for a compact row of short choices. Use OptionCard when previews or descriptions help compare options. RadioList retains native form radio semantics.

Live demo

Export format
Choose the exported image format.
radio-list/basic.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<RadioList
			label="Export format"
			defaultValue="png"
			description="Choose the exported image format."
		>
			<RadioListItem value="png" label="PNG" />
			<RadioListItem value="svg" label="SVG" />
			<RadioListItem value="jpeg" label="JPEG" disabled />
		</RadioList>
	);
}

Anatomy

Export format
Used by the export button.

Tap a part to outline it in the demo.

  1. 01RadioListradiolistclasses.root
  2. 02RadioListradiolist-labelclasses.label
  3. 03RadioListradiolist-itemsclasses.items
  4. 04RadioListradiolist-descriptionclasses.description
  5. 05RadioListradiolist-error-messageclasses.errorMessage
  6. 06RadioListItemradiolist-itemclasses.item
  7. 07RadioListItemradiolist-item-controlclasses.itemControl
  8. 08RadioListItemradiolist-item-indicatorclasses.itemIndicator
  9. 09RadioListItemradiolist-item-labelclasses.itemLabel
ExportRendersclasses keydata-cuiRole
RadioListdivrootradiolistradiogroup
RadioListspanlabelradiolist-labelnone
RadioListdivitemsradiolist-itemsnone
RadioListdivdescriptionradiolist-descriptionnone
RadioListdiverrorMessageradiolist-error-messagenone
RadioListItemdivitemradiolist-itemnone
RadioListItemdivitemControlradiolist-item-controlnone
RadioListItemdivitemIndicatorradiolist-item-indicatornone
RadioListItemlabelitemLabelradiolist-item-labelnone

Each item also renders a native radio input without a data-cui name. Item classes merge with group classes.

Variants

Export format (xs)
Export format (sm)
Export format (md)
Export format (lg)
Export format (xl)
radio-list/sizes.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<div style={{ display: "grid", gap: "var(--cui-space-4)" }}>
			<RadioList label="Export format (xs)" size="xs" defaultValue="png">
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
				<RadioListItem value="jpeg" label="JPEG" disabled />
			</RadioList>
			<RadioList label="Export format (sm)" size="sm" defaultValue="png">
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
				<RadioListItem value="jpeg" label="JPEG" disabled />
			</RadioList>
			<RadioList label="Export format (md)" size="md" defaultValue="png">
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
				<RadioListItem value="jpeg" label="JPEG" disabled />
			</RadioList>
			<RadioList label="Export format (lg)" size="lg" defaultValue="png">
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
				<RadioListItem value="jpeg" label="JPEG" disabled />
			</RadioList>
			<RadioList label="Export format (xl)" size="xl" defaultValue="png">
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
				<RadioListItem value="jpeg" label="JPEG" disabled />
			</RadioList>
		</div>
	);
}
Export format
radio-list/horizontal.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<RadioList label="Export format" orientation="horizontal">
			<RadioListItem value="png" label="PNG" />
			<RadioListItem value="svg" label="SVG" />
			<RadioListItem value="jpeg" label="JPEG" disabled />
		</RadioList>
	);
}
Export format
radio-list/vertical.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<RadioList label="Export format" orientation="vertical">
			<RadioListItem value="png" label="PNG" />
			<RadioListItem value="svg" label="SVG" />
			<RadioListItem value="jpeg" label="JPEG" disabled />
		</RadioList>
	);
}

variant accepts filled and inline through BaseFieldProps. inline, the default, draws each circle as an outline on the surface. filled gives the circle the field fill (--cui-surface-input) and no outline. The root carries data-field-variant.

States

Export format
radio-list/controlled.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
import { createSignal } from "solid-js";
export default function Demo() {
	const [value, setValue] = createSignal("png");
	return (
		<RadioList label="Export format" value={value()} onChange={setValue}>
			<RadioListItem value="png" label="PNG" />
			<RadioListItem value="svg" label="SVG" />
			<RadioListItem value="jpeg" label="JPEG" disabled />
		</RadioList>
	);
}
Export format
radio-list/disabled.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<RadioList label="Export format" disabled defaultValue="png">
			<RadioListItem value="png" label="PNG" />
			<RadioListItem value="svg" label="SVG" />
			<RadioListItem value="jpeg" label="JPEG" disabled />
		</RadioList>
	);
}
Export format
radio-list/read-only.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<RadioList label="Export format" readOnly defaultValue="png">
			<RadioListItem value="png" label="PNG" />
			<RadioListItem value="svg" label="SVG" />
			<RadioListItem value="jpeg" label="JPEG" disabled />
		</RadioList>
	);
}
Export format
radio-list/required.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<RadioList label="Export format" required>
			<RadioListItem value="png" label="PNG" />
			<RadioListItem value="svg" label="SVG" />
			<RadioListItem value="jpeg" label="JPEG" disabled />
		</RadioList>
	);
}
Export options (xs)
Export options (sm)
Export options (md)
Export options (lg)
Export options (xl)
radio-list/invalid.tsx
import { RadioList, RadioListItem } from "@codeui/solid";
export default function Demo() {
	return (
		<div style={{ display: "grid", gap: "var(--cui-space-4)" }}>
			<RadioList
				size="xs"
				label="Export options (xs)"
				validationState="invalid"
				errorMessage="Choose an export option."
			>
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
			</RadioList>
			<RadioList
				size="sm"
				label="Export options (sm)"
				validationState="invalid"
				errorMessage="Choose an export option."
			>
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
			</RadioList>
			<RadioList
				size="md"
				label="Export options (md)"
				validationState="invalid"
				errorMessage="Choose an export option."
			>
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
			</RadioList>
			<RadioList
				size="lg"
				label="Export options (lg)"
				validationState="invalid"
				errorMessage="Choose an export option."
			>
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
			</RadioList>
			<RadioList
				size="xl"
				label="Export options (xl)"
				validationState="invalid"
				errorMessage="Choose an export option."
			>
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
			</RadioList>
		</div>
	);
}

Ready API

RadioList

Renders the complete field. RadioListProps is the public props type.

Prop

Type

Prop

Type

Inherited behavior follows the Kobalte radio-group contract.

RadioListItem

Renders one selectable option.

Prop

Type

Prop

Type

Styled parts API

Use @codeui/solid/radio-list/parts when the ready item cannot express the option layout. Put group Label, Description, and ErrorMessage inside Root. Place each Item in Items. Give each item a value, an ItemInput, an ItemControl containing its ItemIndicator, and an ItemLabel. Use ItemDescription for supporting text.

Accessibility

Keyboard

KeyAction
TabEnter or leave the group.
Arrow keysMove to and select an enabled radio.
SpaceSelect the focused radio.

ARIA

The root has role="radiogroup". Item inputs are native radios with checked state. Labels name each item. Description and error components associate hint text with the field. validationState="invalid" exposes invalid state. Supply a visible label or an accessible name.

Focus

These controls do not open an overlay or move focus on mount. The native radio input is visually hidden, so keyboard focus draws the 2px focus ring around the circle on :focus-visible. Disabled controls cannot receive keyboard focus. Read-only controls remain focusable and do not change value.

SSR notes

The root, labels, controls, and form inputs render on the server. No part uses a portal. Keep initial values and component order stable between server and client so generated IDs hydrate consistently. Create signals per component instance.

Theming hooks

The component reads these foundation variables. Shared field labels and messages also use the field typography and validation tokens.

--cui-action-brand-base, --cui-action-brand-text, --cui-action-danger-base, --cui-border-width, --cui-font-line-height-normal, --cui-motion-duration-normal, --cui-motion-ease-out, --cui-radius-full, --cui-space-1, --cui-space-3, --cui-space-4, --cui-surface-input, --cui-text-hint.

Composition examples

Export format
radio-list/form.tsx
import { RadioList, RadioListItem, Button } from "@codeui/solid";
import { createSignal, For } from "solid-js";
export default function Demo() {
	const [result, setResult] = createSignal("");
	return (
		<form
			onSubmit={event => {
				event.preventDefault();
				setResult(
					new FormData(event.currentTarget).get("format")?.toString() ?? "omitted",
				);
			}}
		>
			<RadioList label="Export format" name="format" defaultValue="png">
				<RadioListItem value="png" label="PNG" />
				<RadioListItem value="svg" label="SVG" />
				<RadioListItem value="jpeg" label="JPEG" disabled />
			</RadioList>
			<Button type="submit">Inspect form value</Button>
			<output>{result()}</output>
		</form>
	);
}

The form demo reads the submitted value with FormData. The selected enabled item submits its value under the group name. An empty selection or disabled group submits no entry.

Use SegmentedControl for a compact row of short choices. Use OptionCard when previews or descriptions help compare options. RadioList retains native form radio semantics. See Control helpers for custom compositions.

On this page