Radio Group
A radio group allows a user to select a single item from a list of mutually exclusive options.
Example
Features
Radio groups can be built in HTML with the <fieldset> and <input> elements, however these can be difficult to style. RadioGroup and Radio help achieve accessible radio groups that can be styled as needed.
- Accessible – Radio groups are exposed to assistive technology via ARIA, and automatically associate a nested
<Label>. Description and error message help text slots are supported as well. - HTML form integration – Each individual radio uses a visually hidden
<input>element under the hood, which enables HTML form integration and autofill. - Validation – Support for native HTML constraint validation with customizable UI, custom validation functions, and server-side validation errors.
- Cross-browser – Mouse, touch, keyboard, and focus interactions are normalized to ensure consistency across browsers and devices.
Installation
Field. Make sure you have installed and configured it before using this component.Install following dependencies:
npm install react-aria-components tw-animate-css tailwindcss-react-aria-components class-variance-authority lucide-react clsx tailwind-merge motionAdd cn helper using clsx and twMerge for conditional class merging in Tailwind components.
Copy and paste the following code into your project.
npx @libravelui@latest add radio-groupAnatomy
import { RadioGroup, Radio } from "@/components/ui/core/radio-group";<RadioGroup
label="Select an Option"
description="Choose one of the available options below."
>
<Radio
value="option-1"
label="Option 1"
description="This is the first available option."
/>
<Radio
value="option-2"
label="Option 2"
description="This is the second available option."
/>
</RadioGroup>Another Examples
Controlled
Handle the radio group’s state externally, giving developers complete control over selection behavior and integration with other form logic.
Validated
Display validation states for radio inputs, such as error or success feedback, to help users make correct selections and improve form accuracy.
Props
Loading types…
Number Field
A number field allows a user to enter a number, and increment or decrement the value using stepper buttons.
Search Bar
A search bar component that lets users enter keywords to quickly find and filter content. It’s designed to be accessible, responsive, and easy to integrate into any interface.