Directory
- Welcome
Radio Group Component
The RadioGroup component helps organize related radio buttons into logical groups. It provides semantic structure, accessibility features, and flexible styling options.
Key Features
-
Semantic Structure: Uses proper fieldset/legend elements
-
Accessibility: Built with ARIA support and keyboard navigation
-
Flexible Styling: Customizable appearance for group and title
-
Nested Content: Works with radio buttons and custom content
Basic Usage
Create a simple radio group with a title:
<RadioGroup title="Select your plan" titleProps={{ class: 'text-lg mb-2' }}> <Checkbox type="radio" name="plan" value="basic">Apple</Checkbox> <Checkbox type="radio" name="plan" value="pro">Banana</Checkbox> <Checkbox type="radio" name="plan" value="enterprise">Cherry</Checkbox></RadioGroup>
Variants
Basic Group
<RadioGroup title="Choose your theme"> <Checkbox type="radio" name="theme" value="light">Light</Checkbox> <Checkbox type="radio" name="theme" value="dark">Dark</Checkbox> <Checkbox type="radio" name="theme" value="system">System</Checkbox></RadioGroup>
Styled Group
<RadioGroup title="Select Layout" titleProps={{ class: 'font-bold text-xl text-primary' }} class="rounded-card p-4 pt-0 border"> <Checkbox type="radio" name="layout" value="compact">Compact</Checkbox> <Checkbox type="radio" name="layout" value="comfortable">Comfortable</Checkbox> <Checkbox type="radio" name="layout" value="spacious">Spacious</Checkbox></RadioGroup>
Props API
Prop | Type | Default | Description |
---|---|---|---|
title | string | Group title text | |
titleProps | HTMLAttributes<legend> | Props for the title element |
Limited Time Launch Sale
Create intuitive form experiences with our pre-built RadioGroup component. Get the AstroJS starter template now!
GET 60% OFF!