Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Radio Group

A set of checkable buttons, known as radio buttons, where no more than one of the buttons can be checked at a time.

Installation

pnpm add @heyramzi/ui bits-ui

Usage

import * as RadioGroup from "@heyramzi/ui/shadcn/radio-group";
<RadioGroup.Root value="comfortable">
  <RadioGroup.Item value="default" id="r1" />
  <label for="r1">Default</label>
  <RadioGroup.Item value="comfortable" id="r2" />
  <label for="r2">Comfortable</label>
</RadioGroup.Root>

Keyboard and accessibility

Key Does
Tab Moves focus to the checked item, or the first one. The group is one stop.
Arrow Down Moves focus to the next item and checks it.
Arrow Up Moves focus to the previous item and checks it.
Space Checks the focused item.
  • With orientation="horizontal", ArrowRight and ArrowLeft move instead.
  • Until something is checked, the arrow keys only move focus.
  • Focus loops from the last item back to the first unless loop is false.

API reference

RadioGroup.Root

ref bindable HTMLElement | null
Default null
class string
value bindable string
Default ""
...rest
Every prop of RadioGroup.Root from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
value bindable string ""
...rest Every prop of RadioGroup.Root from bits-ui

RadioGroup.Item

ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of RadioGroup.Item from bits-ui except child, children
Prop Type Default
ref bindable HTMLElement | null null
class string
...rest Every prop of RadioGroup.Item from bits-ui except child, children