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>
The following directives are available to import from the ng-primitives/radio
package:
Apply the ngpRadioGroup
directive to an element that represents the group of radio items.
[ngpRadioGroup]
ngpRadioGroup
Apply the ngpRadioItem
directive to an element that represents a radio item. This would typically be a button
element.
[ngpRadioItem]
ngpRadioItem
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 |
The disabled state of the radio item. | true | false |
The following data attributes are applied to the ngpRadioItem
directive:
Attribute | Description | Value |
---|---|---|
data-checked |
The checked state of the radio item. | true | false |
data-disabled |
The disabled state of the radio item. | true | false |
data-hover |
The hover state of the radio item. | true | false |
data-focus-visible |
The focus state of the radio item. | true | false |
data-press |
The press state of the radio item. | true | false |
Apply the ngpRadioIndicator
directive to an element that represents the radio indicator (i.e. the dot).
The following data attributes are applied to the ngpRadioItem
directive:
Attribute | Description | Value |
---|---|---|
data-checked |
The checked state of the radio item. | true | false |
data-disabled |
The disabled state of the radio item. | true | false |
data-hover |
The hover state of the radio indicator. | true | false |
data-press |
The press state of the radio indicator. | true | false |
Adheres to the Radio Group WAI-ARIA design pattern.
Copyright © 2024 Angular Primitives