Primitives
Selection within a group.
Import the Radio primitives from ng-primitives/radio.
import { NgpRadioGroup, NgpRadioItem, NgpRadioIndicator } from 'ng-primitives/radio';
Assemble the radio directives in your template.
<div ngpRadioGroup [(ngpRadioGroupValue)]="value">
<button ngpRadioItem ngpRadioItemValue="Option 1">
<ng-icon ngpRadioIndicator name="dot" />
Option 1
</button>
<button ngpRadioItem ngpRadioItemValue="Option 2">
<ng-icon ngpRadioIndicator name="dot" />
Option 2
</button>
<button ngpRadioItem ngpRadioItemValue="Option 3">
<ng-icon ngpRadioIndicator name="dot" />
Option 3
</button>
</div>
Create a reusable component that uses the radio directives.
Generate a reusable radio component using the Angular CLI.
ng g ng-primitives:primitive radio
path: The path at which to create the component file.prefix: The prefix to apply to the generated component selector.componentSuffix: The suffix to apply to the generated component class name.fileSuffix: The suffix to apply to the generated component file name. Defaults to component.exampleStyles: Whether to include example styles in the generated component file. Defaults to true.The following directives are available to import from the ng-primitives/radio package:
The following data attributes are applied to the ngpRadioGroup directive:
| Attribute | Description | Value |
|---|---|---|
data-orientation |
The orientation of the radio group. | vertical | horizontal |
data-disabled |
Applied when the radio group is disabled. | - |
The following data attributes are applied to the ngpRadioItem directive:
| Attribute | Description |
|---|---|
data-checked |
Applied when the radio item is checked. |
data-disabled |
Applied when the radio item is disabled. |
data-hover |
Applied when the radio item is hovered. |
data-focus-visible |
Applied when the radio item is focused. |
data-press |
Applied when the radio item is pressed. |
The following data attributes are applied to the ngpRadioItem directive:
| Attribute | Description |
|---|---|
data-checked |
Applied when the radio item is checked. |
data-disabled |
Applied when the radio item is disabled. |
data-hover |
Applied when the radio item is hovered. |
data-press |
Applied when the radio item is pressed. |
Adheres to the Radio Group WAI-ARIA design pattern.
Copyright © 2026 Angular Primitives
This site is powered by Netlify