Primitives
A search field is a form control that allows users to enter a search query.
Import the SearchField primitives from ng-primitives/search
.
import { NgpSearchField, NgpSearchFieldClear } from 'ng-primitives/search';
Assemble the search-field directives in your template.
<div ngpSearchField>
<label ngpLabel>Label</label>
<input ngpInput type="search" />
<button ngpButton ngpSearchFieldClear aria-label="Clear search">Clear</button>
</div>
The following directives are available to import from the ng-primitives/search
package:
The NgpSearchField
directive is a container for the search field components.
[ngpSearchField]
ngpSearchField
Attribute | Description | Value |
---|---|---|
data-empty |
Whether the associated input is empty. | true | false |
data-invalid |
The invalid state of the form control. |
true | false |
data-valid |
The valid state of the form control. |
true | false |
data-touched |
The touched state of the form control. |
true | false |
data-pristine |
The pristine state of the form control. |
true | false |
data-dirty |
The dirty state of the form control. |
true | false |
data-pending |
The pending state of the form control. |
true | false |
data-disabled |
The disabled state of the form control. |
true | false |
The NgpSearchFieldClear
directive is can be added to a button to clear the search field on click.
[ngpSearchFieldClear]
ngpSearchFieldClear
Attribute | Description | Value |
---|---|---|
data-empty |
Whether the associated input is empty. | true | false |
Adheres to the Search WAI-ARIA design pattern.
Copyright © 2024 Angular Primitives