Radio Group
Usage
Radio Group presents a set of mutually exclusive options where only one selection is allowed. Use it when the available choices should stay visible on the page instead of being hidden in a collapsed control, and when users benefit from scanning or comparing a small number of options before choosing one.
import {
MtRadioGroupRoot,
MtRadioGroupList,
MtRadioGroupItem,
MtRadioGroupCustomItem,
MtRadioGroupIndicator,
} from "@shopware-ag/meteor-component-library";
Examples
Custom item
Build fully custom option cards while keeping the shared radio-group state.
Anatomy
Radio Group is a compound component made up of several public exports:
MtRadioGroupRootprovides the shared label, help text, hint, error handling, and selected-value state.MtRadioGroupListlays out a standard vertical list of radio items with the expected spacing.MtRadioGroupItemrenders the default radio option with a label.MtRadioGroupCustomItemlets you build fully custom option cards while still participating in the shared radio-group state.MtRadioGroupIndicatorrenders the actual radio input and control, and is mainly useful inside custom-item compositions.
API reference
Props
| Prop | Type | Default |
|---|---|---|
model-value | string | number | boolean | null | null |
disabled | boolean | false |
aria-described-by | string | undefined |
label | string | "" |
help-text | string | "" |
name | string | undefined |
error | { detail: string; } | undefined |
Events
| Event | Payload |
|---|---|
update:modelValue | [value: string | number | boolean | null] |
Slots
| Slot | Bindings |
|---|---|
default | { disabled: boolean; identification: string; } |
hint | {} |
Best practices
Do
- Use clear, concise labels for each option.
- Use a descriptive group label that explains what the user is selecting.
- Include help text or a hint when the selection needs additional context.
- Use the
errorprop to display validation errors when needed. - Ensure each radio item has a unique
idandvalue. - Use
MtRadioGroupListto wrap multipleMtRadioGroupItemcomponents for proper spacing. - Use
MtRadioGroupCustomItemwhen you need custom-styled radio options such as pricing plans or feature cards. - Keep the number of options manageable. A small visible set is the sweet spot.
Don't
- Do not use Radio Group for multiple selections. Use Checkbox instead.
- Do not use a single radio button. Radio groups should present a real choice.
- Do not omit labels. Always provide clear labels for accessibility and usability.
- Do not use radio groups for long lists of options where a Select would be easier to scan.
- Do not use the same
valuefor multiple items within the same group. - Do not forget to handle the
v-modelbinding so the selected value stays in sync.
Behavior
- Radio Group uses
v-modelonMtRadioGroupRootto manage the selected value across all items in the group. MtRadioGroupItemshould always be used insideMtRadioGroupRoot, because it depends on the shared radio-group context.MtRadioGroupCustomItemgives you layout freedom, but you still need to renderMtRadioGroupIndicatorso the custom option remains a real radio control.helpText,hint, anderrorfollow the shared field patterns used by other form components.
Accessibility
- Provide a clear group label or other nearby visible context so users understand what the choice controls.
MtRadioGroupIndicatoruses native radio inputs, so the group benefits from standard browser keyboard behavior.- Keep option labels explicit so users do not need surrounding context to understand each choice.
- If you build custom items, make sure the visible content still makes the selected state and choice meaning clear.