Primitives
Perform state toggling.
Import the Checkbox primitives from ng-primitives/checkbox
.
import { NgpCheckbox } from 'ng-primitives/checkbox';
Assemble the checkbox directives in your template.
<span ngpCheckbox [(ngpCheckboxChecked)]="checked">
<ng-icon name="checkmark" aria-hidden="true" />
</span>
Generate a checkbox component with the NgpCheckbox
primitive preconfigured.
ng g ng-primitives:checkbox
Here are some additional examples of how to use the Checkbox primitives.
The checkbox automatically integrates with the form field primitives.
The following directives are available to import from the ng-primitives/checkbox
package:
Apply the ngpCheckbox
directive to an element to that represents the checkbox, such as a button
.
[ngpCheckbox]
ngpCheckbox
Attribute | Description |
---|---|
data-checked |
Applied when the checkbox is checked. |
data-indeterminate |
Applied when the checkbox is indeterminate. |
data-disabled |
Applied when the checkbox is disabled. |
data-hover |
Applied when the checkbox is hovered. |
data-focus-visible |
Applied when the checkbox is focused. |
data-press |
Applied when the checkbox is pressed. |
Adheres to the Tri-State Checkbox WAI-ARIA design pattern.
Copyright © 2024 Angular Primitives