Radio
Radio buttons are essential form controls that present users with a clear set of options where only one selection is possible at a time.
import {RadioModule} from "@qualcomm-ui/angular/radio"Examples
Simple
The simple API bundles all Radio Item subcomponents together into a single q-radio directive.
<fieldset defaultValue="html" name="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label label="HTML" q-radio value="html"></label>
<label label="CSS" q-radio value="css"></label>
<label label="TypeScript" q-radio value="ts"></label>
</div>
</fieldset>
Child Directives
Provide child directives to customize specific elements while keeping the simple API's default structure.
<fieldset defaultValue="html" name="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label q-radio value="html">
<div q-radio-label>HTML</div>
</label>
<label q-radio value="css">
<div q-radio-label>CSS</div>
</label>
<label q-radio value="ts">
<div q-radio-label>TypeScript</div>
</label>
</div>
</fieldset>
Composite
Build with the composite API for granular control. This API requires you to provide each subcomponent, but gives you full control over the structure and layout.
<fieldset defaultValue="html" name="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label q-radio-root value="html">
<input q-radio-hidden-input />
<div q-radio-control></div>
<span q-radio-label>HTML</span>
</label>
<label q-radio-root value="css">
<input q-radio-hidden-input />
<div q-radio-control></div>
<span q-radio-label>CSS</span>
</label>
<label q-radio-root value="ts">
<input q-radio-hidden-input />
<div q-radio-control></div>
<span q-radio-label>TypeScript</span>
</label>
</div>
</fieldset>
Layout
Use the composite API when you need to modify the layout of the radio buttons.
<fieldset defaultValue="html" name="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label q-radio-root value="html">
<input q-radio-hidden-input />
<span q-radio-label>HTML</span>
<div q-radio-control></div>
</label>
<label q-radio-root value="css">
<input q-radio-hidden-input />
<span q-radio-label>CSS</span>
<div q-radio-control></div>
</label>
<label q-radio-root value="ts">
<input q-radio-hidden-input />
<span q-radio-label>TypeScript</span>
<div q-radio-control></div>
</label>
</div>
</fieldset>
Disabled
When disabled is true, the radio group becomes non-interactive and is rendered with reduced opacity to indicate its unavailable state.
<fieldset defaultValue="html" disabled name="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label label="HTML" q-radio value="html"></label>
<label label="CSS" q-radio value="css"></label>
<label label="TypeScript" q-radio value="ts"></label>
</div>
</fieldset>
Orientation
Controls the layout direction of radio buttons within the group.
<fieldset name="language" orientation="horizontal" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label label="HTML" q-radio value="html"></label>
<label label="CSS" q-radio value="css"></label>
<label label="TypeScript" q-radio value="ts"></label>
</div>
<div q-radio-group-error-text>You must select a value</div>
</fieldset>
Sizes
The radio supports three sizes: sm, md (default), and lg.
import {Component} from "@angular/core"
import {RadioModule} from "@qualcomm-ui/angular/radio"
@Component({
imports: [RadioModule],
selector: "radio-sizes-demo",
template: `
<fieldset class="flex flex-col items-center gap-4" q-radio-group>
<div q-radio-group-items>
<label label="small (sm)" q-radio size="sm" value="sm"></label>
<label label="medium (md)" q-radio size="md" value="md"></label>
<label label="large (lg)" q-radio size="lg" value="lg"></label>
</div>
</fieldset>
`,
})
export class RadioSizesDemo {}Indented
Use indented to indent the radio items.
<fieldset defaultValue="html" indented name="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label label="HTML" q-radio value="html"></label>
<label label="CSS" q-radio value="css"></label>
<label label="TypeScript" q-radio value="ts"></label>
</div>
</fieldset>
Hint
Add a hint to provide additional context for the radio group.
<fieldset defaultValue="html" name="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label label="HTML" q-radio value="html"></label>
<label label="CSS" q-radio value="css"></label>
<label label="TypeScript" q-radio value="ts"></label>
</div>
<div q-radio-group-hint>You can change this later</div>
</fieldset>
Forms
Template Forms
When using template-driven forms with ngModel, enable validation by adding the required attribute directly to the template:
Guidelines:
- When using template forms, add the required attribute to trigger validation
- The component automatically handles validation state checking
- The
q-radio-group-error-textdirective displays automatically when the field is invalid and the user has interacted with it
Full example:
<div name="language" q-radio-group required [(ngModel)]="value">
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label label="HTML" q-radio value="html"></label>
<label label="CSS" q-radio value="css"></label>
<label label="TypeScript" q-radio value="ts"></label>
</div>
<div q-radio-group-error-text>You must select a value</div>
</div>
Reactive Forms
Use Reactive Forms instead of Template-driven Forms for better control over form state and validation.
<fieldset formControlName="language" q-radio-group>
<div q-radio-group-label>Language</div>
<div q-radio-group-items>
<label label="HTML" q-radio value="html"></label>
<label label="CSS" q-radio value="css"></label>
<label label="TypeScript" q-radio value="ts"></label>
</div>
<div q-radio-group-error-text>You must select a value</div>
</fieldset>
Composition
RadioGroup
The Radio is only intended to be used as direct descendants of the q-radio-group directive.
<!-- Won't work alone ❌ -->
<label q-radio label="Label" value="value"></label>
<!-- Works as expected ✅ -->
<fieldset q-radio-group>
<label q-radio label="Label" value="value"></label>
</fieldset>Radio buttons are designed for groups. For single toggle controls, use the Checkbox component instead.
Composite Components
The Radio's composite components are only intended to be used as direct descendants of the q-radio-root directive.
<!-- Won't work alone ❌ -->
<input q-radio-hidden-input />
<span q-radio-control></span>
<span q-radio-label>Label</span>
<!-- Works as expected ✅ -->
<label q-radio-root value="value">
<input q-radio-hidden-input />
<span q-radio-control></span>
<span q-radio-label>Label</span>
</label>Accessibility
- Always use the associated label or q-radio-label directive when authoring each radio item's text label. This is automatically associated with the input element.
- If you omit a visible item label, give the radio item an accessible name with aria-label or aria-labelledby on the simple
q-radio. If you use the composite API, providearia-labeloraria-labelledbyon theq-radio-hidden-inputelement. Avoid[attr.aria-label]and[attr.aria-labelledby]; use[aria-label]or[aria-labelledby]for dynamic values.
<fieldset defaultValue="email" name="notification" q-radio-group>
<div q-radio-group-label>Notification preference</div>
<div q-radio-group-items>
<label aria-label="Email" q-radio value="email"></label>
<label aria-label="SMS" q-radio value="sms"></label>
<label aria-label="Push" q-radio value="push"></label>
</div>
</fieldset>
Explorer
Component Anatomy
Hover to highlight, click to view API
API
q-radio-group
string'ltr' | 'rtl'
boolean() =>
| Node
| ShadowRoot
| Document
stringbooleanstring| 'horizontal'
| 'vertical'
booleanboolean| 'sm'
| 'md'
| 'lg'
stringclass'qui-radio-group__root'data-disableddata-orientation| 'horizontal'
| 'vertical'
data-radio-part'group'q-radio-group-label
stringclass'qui-radio-group__label'data-disableddata-radio-part'label'data-size| 'sm'
| 'md'
| 'lg'
q-radio-group-items
class'qui-radio-group__items'data-indenteddata-orientation| 'horizontal'
| 'vertical'
data-radio-part'items'data-size| 'sm'
| 'md'
| 'lg'
q-radio-group-hint
stringclass'qui-input__hint'data-disableddata-radio-part'hint'hiddenbooleanq-radio-group-error-text
| LucideIconData
| string
stringclass'qui-input__error-text'data-radio-part'error-text'hiddenbooleanq-radio
The q-radio directive supports all props from q-radio-root directive, plus the props listed below.
stringstringstring<label q-radio>
<div q-radio-hint>...</div>
</label>
string<label q-radio>
<div q-radio-label>...</div>
</label>
Composite API
q-radio-root
stringbooleanq-radio-group disabled property, if set to true, will override
this input.string| 'sm'
| 'md'
| 'lg'
class'qui-radio__root'data-disableddata-focusdata-focus-visibledata-hoverdata-invaliddata-radio-part'item'data-readonlydata-state| 'checked'
| 'unchecked'
q-radio-label
stringclass'qui-radio__label'data-disableddata-focusdata-focus-visibledata-hoverdata-invaliddata-radio-part'item-label'data-readonlydata-size| 'sm'
| 'md'
| 'lg'
data-state| 'checked'
| 'unchecked'
q-radio-control
class'qui-radio__control'data-activedata-disableddata-focusdata-focus-visibledata-hoverdata-invaliddata-radio-part'item-control'data-readonlydata-size| 'sm'
| 'md'
| 'lg'
data-state| 'checked'
| 'unchecked'
q-radio-hidden-input
stringstringstringclass'qui-radio__hidden-input'data-disableddata-focusdata-focus-visibledata-hoverdata-invaliddata-ownedbystringdata-radio-part'item-hidden-input'data-readonlydata-state| 'checked'
| 'unchecked'
styleq-radio-hint
stringclass'qui-input__hint'data-disableddata-focusdata-focus-visibledata-hoverdata-invaliddata-radio-part'item-hint'data-readonlydata-state| 'checked'
| 'unchecked'
hiddenboolean