Skip to content

Radio Group

One choice out of a few, all visible at once, with keyboard arrows and a springy dot.

Base UI1.6 kB gzipSource Registry JSON

RadioGroup playground

Plan

Props

orientation

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/radio-group.json

The CLI writes components/ikada/radio-group.tsx and merges the ikada theme into your CSS. Or take it from the package: import { RadioGroup } from "@sproutboat/ikada";

Usage

import { RadioGroup } from "@/components/ikada/radio-group";

<RadioGroup
  legend="Plan"
  defaultValue="free"
  options={[
    { value: "free", label: "Free" },
    { value: "pro", label: "Pro" },
  ]}
/>

Examples

Vertical

Arrow keys move and select; Tab leaves the group.
Plan

Descriptions

Region

Horizontal

Visibility

Invalid

Plan

Disabled

Plan

Props

RadioGroupProps
PropTypeDescription
optionsrequiredreadonly RadioOption[]The choices, in order: value, label and an optional description.
legendReactNodeThe group's visible name. Without one, pass `aria-label`.
invalidbooleanMarks the group invalid: danger rings and aria-invalid.
orientation"horizontal" | "vertical"`horizontal` lays the options in a wrapping row. Default `vertical`.
classNamestringClasses merged onto the root element, after ikada's own.
styleCSSProperties | ((state: RadioGroupState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioGroupState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

Also takes every prop of Omit<ComponentProps<typeof BaseRadioGroup>, "className" | "children">.

Source: src/components/radio-group.tsx