Radio
A control element that allows the user to choose only one of a predefined set of mutually exclusive options. The singular property of a radio button makes it distinct from checkboxes, where the user can select and unselect any number of items.
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.
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>API
q-radio-group
| Prop | Type | Default |
|---|---|---|
The initial value of the radio group when rendered. Use when you don't need to
control the state of the radio group. This property will be ignored if you
opt into controlled state via form control bindings. | string | |
The document's text/writing direction. | 'ltr' | 'rtl' | "ltr" |
Controls whether the input is disabled in template-driven forms. When true,
prevents user interaction and applies visual styling to indicate the disabled
state. | boolean | |
A root node to correctly resolve the Document in custom environments. i.e.,
Iframes, Electron. | () => | |
id attribute. If
omitted, a unique identifier will be generated for accessibility.) | string | |
The name of the input field in a radio group. Useful for form submission. | string | |
Orientation of the radio group | | 'horizontal' | 'vertical' |
Whether the input is read-only. When true, prevents user interaction while
keeping the input focusable and visible. | boolean | |
Controls whether the input is required in template-driven forms. When
true, the input must have a value for form validation to pass. | boolean | |
The size of the radio and its elements. Governs properties like label font
size, control size, and indicator size. | | 'sm' | 'md' |
Event emitted when the radio is selected or deselected. This is only emitted
on interaction. It doesn't emit in response to programmatic or form control
changes. | string |
string'ltr' | 'rtl'
boolean() =>
| Node
| ShadowRoot
| Document
stringstring| 'horizontal'
| 'vertical'
booleanboolean| 'sm'
| 'md'
| 'lg'
stringq-radio
The q-radio directive supports all props from q-radio-root directive, plus the props listed below.
| Prop | Type |
|---|---|
Optional label describing the element. Recommended. This element is
automatically associated with the component's input element for accessibility. | string |
stringComposite API
q-radio-root
| Prop | Type | Default |
|---|---|---|
The value of the radio input. This is used to identify which radio is
selected in a group. | string | |
Controls whether the input is disabled in template-driven forms. When true,
prevents user interaction and applies visual styling to indicate the disabled
state. | boolean | |
The parent q-radio-group disabled property, if set to true, will override
this input. | ||
id attribute. If
omitted, a unique identifier will be generated for accessibility.) | string | |
The size of the radio and its elements. Governs properties like label font
size, control size, and indicator size. | | 'sm' | 'md' |
stringbooleanq-radio-group disabled property, if set to true, will override
this input.string| 'sm'
| 'md'
| 'lg'