Free and open-source React radio button components built for modern applications and websites. These radio buttons are built using React Aria and styled with Tailwind CSS.
Installation
You can add this radio button component using our CLI or manually:
npx untitledui@latest add radio-buttons
Radio button examples
Below are examples and variations of this radio button component:
API reference
RadioGroup
Import RadioGroup from @/components/base/radio-buttons/radio-buttons. Renders React Aria’s RadioGroup — all of its props are supported.
Props from React Aria (24)
Also accepts the global HTML attributes (dir, lang, hidden, inert, translate), all standard React DOM event handlers.
FAQs
Please refer to our frequently asked questions page for more.
Wrap RadioButton components in a RadioGroup from the same file and give each one a unique value. RadioButton is built on React Aria's Radio, so it must be rendered inside a RadioGroup.
Set defaultValue on RadioGroup for uncontrolled state, or use value with onChange for controlled state. onChange receives the value of the newly selected RadioButton.
Radio buttons support "sm" and "md", and the default is "sm". Set size on RadioGroup; the group's size overrides any size set on an individual RadioButton inside it.
Use the label prop for the main text and the hint prop for supporting text below it. Both accept React nodes. Leave both out to render only the radio circle.
Set isDisabled on RadioGroup to disable every option, or on a single RadioButton to disable only that one. Disabled radios render at 50% opacity with a not-allowed cursor.
RadioGroup doesn't render a visible group label, so pass aria-label as the examples do, or aria-labelledby pointing to your own heading. React Aria handles keyboard support: Tab moves focus into the group and the arrow keys change the selection.
RadioGroup stacks its options with flex flex-col gap-4 by default. Pass className="flex-row" (or any layout classes) to change it. Classes are merged with tailwind-merge, so yours replace the default classes that conflict.