shadcn-remix
GitHub

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.

import { css } from 'remix/component'

import { Label } from '#app/ui/label.tsx'
import { RadioGroup, RadioGroupItem } from '#app/ui/radio-group.tsx'

const rowStyles = css({ display: 'flex', alignItems: 'center', gap: '0.75rem' })
import { css } from 'remix/component'

import { Label } from '#app/ui/label.tsx'
import { RadioGroup, RadioGroupItem } from '#app/ui/radio-group.tsx'

const rowStyles = css({ display: 'flex', alignItems: 'center', gap: '0.75rem' })

export function RadioGroupDemo() {
  return () => (
    <RadioGroup defaultValue="comfortable">
      <div mix={rowStyles}>
        <RadioGroupItem value="default" id="r1" />
        <Label htmlFor="r1">Default</Label>
      </div>
      <div mix={rowStyles}>
        <RadioGroupItem value="comfortable" id="r2" />
        <Label htmlFor="r2">Comfortable</Label>
      </div>
      <div mix={rowStyles}>
        <RadioGroupItem value="compact" id="r3" />
        <Label htmlFor="r3">Compact</Label>
      </div>
    </RadioGroup>
  )
}

Installation

$ pnpm dlx shadcn@latest add https://www.shadcn-remix.com/r/radio-group.json

Usage

import { css } from 'remix/component'

import { Label } from '#app/ui/label.tsx'
import { RadioGroup, RadioGroupItem } from '#app/ui/radio-group.tsx'
<RadioGroup defaultValue="option-one">
  <div mix={css({ display: 'flex', alignItems: 'center', gap: '0.75rem' })}>
    <RadioGroupItem value="option-one" id="option-one" />
    <Label htmlFor="option-one">Option One</Label>
  </div>
  <div mix={css({ display: 'flex', alignItems: 'center', gap: '0.75rem' })}>
    <RadioGroupItem value="option-two" id="option-two" />
    <Label htmlFor="option-two">Option Two</Label>
  </div>
</RadioGroup>

API Reference

RadioGroup

A set of checkable buttons where no more than one can be checked at a time. Arrow keys move focus between items and check the focused one; only one item is in the tab order.

PropTypeDefault
valuestring-
defaultValuestring-
onValueChange((value: string) => void)-
namestring-
requiredboolean-
disabledboolean-
orientation"horizontal" | "vertical"-
dir"rtl" | "ltr"-
loopboolean-
mixMixValue-

RadioGroupItem

PropTypeDefault
valuestring-
requiredboolean-
mixMixValue-