# Table of Contents
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
- [Angular Primitives](#angular-primitives)
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Introduction
============
Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. Whether you're building a robust design system from scratch or looking to enhance your existing one, our primitives are here to support you every step of the way.
Key Features
------------
1. **Accessibility First:** We believe that all users should have equal access to information and functionality. Our primitives are crafted with accessibility best practices, ensuring that your applications are inclusive and usable by everyone.
2. **Customization Made Easy:** We understand the importance of maintaining a consistent look and feel across your applications. With Angular Primitives, we don't provide any styles, you provide your own to seamlessly blend with your brand's identity and visual guidelines.
3. **Developer Experience:** We know developers value simplicity and efficiency. Our library is designed to be intuitive and straightforward, making it a breeze for you to integrate and work with our primitives in your Angular projects. We follow the best practices and standards to ensure the highest quality code and documentation.
Versioning
----------
Angular Primitives follow [Semantic Versioning](https://semver.org/)
. As a result you can expect the following:
* **Patch releases** contain bug fixes and minor improvements.
* **Minor releases** contain new features and improvements.
* **Major releases** contain breaking changes.
We release a new major version each time Angular releases a new major version. This ensures that Angular Primitives is always up-to-date with the latest Angular features and best practices.
Compatibility
-------------
Angular Primitives versions are compatible with the following Angular versions:
| Angular Primitives | Angular |
| --- | --- |
| 0.1.0 - 0.18.0 | 18.0.x |
| 0.19.0+ | 19.0.x |
### Version Support Policy
Starting from v1.0.0, Angular Primitives will support the two latest major Angular versions. For example, when Angular 21 is released, Angular Primitives will support Angular 20 and 21. New major versions will be supported upon release (typically every six months), ensuring compatibility with the latest Angular features while allowing you to upgrade independently.
Community
---------
If you would like to stay up-to-date with the latest news and updates, or have any questions, feedback, or suggestions, we invite you to join our community on [Discord](https://discord.gg/NTdjc5r3gC)
.
Acknowledgements
----------------
Angular Primitives would not have been possible without inspiration from many of the great libraries that came before it. We would like to thank the following projects for their contributions to the open-source community:
* [Angular CDK](https://material.angular.io/cdk)
* [Radix UI](https://radix-ui.com/)
* [Headless UI](https://headlessui.com/)
* [React Aria](https://react-spectrum.adobe.com/react-aria/)
Support
-------
If you have any questions, feedback, or need help, feel free to reach out to us on [GitHub](https://github.com/ng-primitives/ng-primitives)
. We're always happy to help and improve our library based on your feedback.
If you're interested in contributing to Angular Primitives, please check out our [Contributing Guide](https://github.com/ng-primitives/ng-primitives/blob/main/CONTRIBUTING.md)
.
If you would like to support Angular Primitives to help us maintain and improve the library, please consider [sponsoring us](https://github.com/sponsors/ng-primitives)
. Your support is greatly appreciated!
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Visually Hidden
===============
Hide an element visually while keeping it present in the DOM. This is particularly useful for accessibility purposes, ensuring that screen readers and other assistive technologies can still interact with the hidden content.
Import
------
Import the VisuallyHidden primitives from `ng-primitives/a11y`.
import { NgpVisuallyHidden } from 'ng-primitives/a11y';
Usage
-----
Assemble the visually-hidden directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/a11y` package:
### NgpVisuallyHidden
Hide an element visually while keeping it present in the DOM.
* Selector: `[ngpVisuallyHidden]`
* Exported As: `ngpVisuallyHidden`
Accessibility
-------------
This directive can be useful for hiding content that is still important for screen readers and other assistive technologies.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Tooltip
=======
Display additional information on hover.
Import
------
Import the Tooltip primitives from `ng-primitives/tooltip`.
import { NgpTooltip } from 'ng-primitives/tooltip';
Usage
-----
Assemble the tooltip directives in your template.
Hover me
Tooltip content
API Reference
-------------
The following directives are available to import from the `ng-primitives/tooltip` package:
### NgpTooltip
Apply the `ngpTooltip` directive to an element that represents the tooltip. This typically would be a `div` inside an `ng-template`.
* Selector: `[ngpTooltip]`
* Exported As: `ngpTooltip`
### NgpTooltipTrigger
Apply the `ngpTooltipTrigger` directive to an element that triggers the tooltip to show.
* Selector: `[ngpTooltipTrigger]`
* Exported As: `ngpTooltipTrigger`
Define the content of the tooltip. This should be reference to an \`ng-template\`. Define the open state. Event emitted when the state changes. Define the offset from the trigger element. Define the disabled state. Define the placement of the tooltip. Define the delay before the tooltip shows. Define the delay before the tooltip hides. Define if the tooltip should flip when it reaches the edge of the viewport. Define the container element for the tooltip. This is the document body by default.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-open` | Applied when the popover is open. |
| `data-disabled` | Applied when the tooltip is disabled. |
Global Configuration
--------------------
You can configure the default options for all tooltips in your application by using the `provideTooltipConfig` function in a providers array.
import { provideTooltipConfig } from 'ng-primitives/tooltip';
bootstrapApplication(AppComponent, {
providers: [\
provideTooltipConfig({\
offset: 4,\
placement: 'top',\
showDelay: 0,\
hideDelay: 0,\
flip: true,\
container: document.body,\
}),\
],
});
### NgpTooltipConfig
Define the offset from the trigger element. Define the placement of the tooltip. Define the delay before the tooltip shows. Define the delay before the tooltip hides. Define if the tooltip should flip when it reaches the edge of the viewport. Define the container element for the tooltip. This is the document body by default.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toolbar
=======
The Toolbar primitive is a container for grouping related controls.
Import
------
Import the Toolbar primitives from `ng-primitives/toolbar`.
import { NgpToolbar } from 'ng-primitives/toolbar';
Usage
-----
Assemble the toolbar directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toolbar` package:
### NgpToolbar
* Selector: `[ngpToolbar]`
* Exported As: `ngpToolbar`
The orientation of the toolbar.
#### Data Attributes
The following data attributes are applied to the `ngpToolbar` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the toolbar. | `horizontal` \| `vertical` |
Accessibility
-------------
Adheres to the [WAI-ARIA Toolbar Design Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar)
.
### Keyboard Interaction
* Tab - Moves focus to the first interactive element in the toolbar.
* Arrow Down - Moves focus to the next interactive element (vertical orientation).
* Arrow Up - Moves focus to the previous interactive element (vertical orientation).
* Arrow Right - Moves focus to the next interactive element (horizontal orientation).
* Arrow Left - Moves focus to the previous interactive element (horizontal orientation).
* Home - Moves focus to the first interactive element in the toolbar.
* End - Moves focus to the last interactive element in the toolbar.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Focus Trap
==========
The Focus Trap utility is a directive that traps focus within a specified element. This is useful for modals, dropdowns, and other components that require focus to be contained within a specific area.
Import
------
Import the FocusTrap primitives from `ng-primitives/focus-trap`.
import { NgpFocusTrap } from 'ng-primitives/focus-trap';
Usage
-----
Assemble the focus-trap directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/focus-trap` package:
### NgpFocusTrap
The `NgpFocusTrap` directive traps focus within the host element.
* Selector: `[ngpFocusTrap]`
* Exported As: `ngpFocusTrap`
Disables the focus trap.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-focus-trap` | Applied when focus is trapped. |
Accessibility
-------------
Adheres to the [WAI-ARIA design pattern](https://www.w3.org/TR/UNDERSTANDING-WCAG20/keyboard-operation-trapping.html)
.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Date Adapter
============
The Date Adapter is an abstraction layer that allows components to use date objects from any date library, ensuring compatibility and easy integration.
Import
------
Import the DateAdapter from `ng-primitives/date-time`.
import { NgpLuxonDateAdapter } from 'ng-primitives/date-time-lucon';
import { NgpDateAdapter, NgpNativeDateAdapter } from 'ng-primitives/date-time-luxon';
Usage
-----
Angular Primitives ships with two date adapters out of the box: `NgpNativeDateAdapter` and `NgpLuxonDateAdapter`. The `NgpNativeDateAdapter` uses the native JavaScript `Date` object, while the `NgpLuxonDateAdapter` uses the Luxon date library.
To use a date adapter, you need to provide it to Angular's dependency injection system. This can be done once at the root of your application or at a component/module level.
bootstrapApplication(AppComponent, {
providers: [provideDateAdapter(NgpLuxonDateAdapter)],
});
If no date adapter is provided, the `NgpNativeDateAdapter` will be used by default.
Should you need to use a different date library, you can create your own date adapter by implementing the `NgpDateAdapter` interface.
Should you wish to use the adapter in a component, you can inject it into a component.
import { Component } from '@angular/core';
import { DateTime } from 'luxon';
import { injectDateAdapter } from 'ng-primitives/date-time';
@Component({
selector: 'app-root',
template: `
...
`,
})
export class AppComponent {
private readonly dateAdapter = injectDateAdapter();
}
API Reference
-------------
All date adapters must implement the `NgpDateAdapter` interface.
interface NgpDateAdapter {
/**
* Create a new date time object.
*/
create(values: NgpDateUnits): T;
/**
* Create a new date with the current date and time.
*/
now(): T;
/**
* Set the year of the date time object based on a duration.
*/
set(date: T, values: NgpDateUnits): T;
/**
* Add a duration to the date time object.
*/
add(date: T, duration: NgpDuration): T;
/**
* Subtract a duration from the date time object.
*/
subtract(date: T, duration: NgpDuration): T;
/**
* Compare two date time objects.
*/
compare(a: T, b: T): number;
/**
* Determine if two date time objects are equal.
*/
isEqual(a: T, b: T): boolean;
/**
* Determine if a date time object is before another.
*/
isBefore(a: T, b: T): boolean;
/**
* Determine if a date time object is after another.
*/
isAfter(a: T, b: T): boolean;
/**
* Determine if two date objects are on the same day.
*/
isSameDay(a: T, b: T): boolean;
/**
* Determine if two date objects are on the same month.
*/
isSameMonth(a: T, b: T): boolean;
/**
* Determine if two date objects are on the same year.
*/
isSameYear(a: T, b: T): boolean;
/**
* Get the year.
*/
getYear(date: T): number;
/**
* Get the month.
*/
getMonth(date: T): number;
/**
* Get the date.
*/
getDate(date: T): number;
/**
* Get the day.
*/
getDay(date: T): number;
/**
* Get the hours.
*/
getHours(date: T): number;
/**
* Get the minutes.
*/
getMinutes(date: T): number;
/**
* Get the seconds.
*/
getSeconds(date: T): number;
/**
* Get the milliseconds.
*/
getMilliseconds(date: T): number;
/**
* Get the first day of the month.
*/
startOfMonth(date: T): T;
/**
* Get the last day of the month.
*/
endOfMonth(date: T): T;
/**
* Get the start of the day.
*/
startOfDay(date: T): T;
/**
* Get the end of the day.
*/
endOfDay(date: T): T;
}
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Slider
======
Select a value within a range.
Import
------
Import the Slider primitives from `ng-primitives/slider`.
import { NgpSlider, NgpSliderTrack, NgpSliderRange, NgpSliderThumb } from 'ng-primitives/slider';
Usage
-----
Assemble the slider directives in your template.
Reusable Component
------------------
Create a reusable component that uses the slider directives.
Schematics
----------
Generate a reusable slider component using the Angular CLI.
ng g ng-primitives:primitive slider
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Slider primitives.
### Slider Form Field
The slider automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/slider` package:
### NgpSlider
Apply the `ngpSlider` directive to an element that represents the slider and contains the track, range, and thumb.
* Selector: `[ngpSlider]`
* Exported As: `ngpSlider`
* Host Directives: [NgpFormControl](/primitives/form-field)
Define the selected value. Define the minimum value. Define the maximum value. Define the step value. Define the orientation.
#### Data Attributes
The following data attributes are available to style the slider:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
### NgpSliderTrack
Apply the `ngpSliderTrack` directive to an element that represents the track of the slider.
* Selector: `[ngpSliderTrack]`
* Exported As: `ngpSliderTrack`
#### Data Attributes
The following data attributes are available to style the slider track:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
### NgpSliderRange
Apply the `ngpSliderRange` directive to an element that represents the range of the slider.
* Selector: `[ngpSliderRange]`
* Exported As: `ngpSliderRange`
#### Data Attributes
The following data attributes are available to style the slider range:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
### NgpSliderThumb
Apply the `ngpSliderThumb` directive to an element that represents the thumb of the slider.
* Selector: `[ngpSliderThumb]`
* Exported As: `ngpSliderThumb`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
#### Data Attributes
The following data attributes are available to style the thumb:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-hover` | Applied when the slider thumb is hovered. | `-` |
| `data-focus-visible` | Applied when the slider thumb is focused. | `-` |
| `data-press` | Applied when the slider thumb is pressed. | `-` |
Accessibility
-------------
Adheres to the [Slider WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb)
.
### Keyboard Interactions
* Left Arrow or Down Arrow: Decrease the value by the step.
* Right Arrow or Up Arrow: Increase the value by the step.
* Left Arrow or Down Arrow + Shift: Decrease the value by the step by a larger amount.
* Right Arrow or Up Arrow + Shift: Increase the value by the step by a larger amount.
* Home: Set the value to the minimum.
* End: Set the value to the maximum.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toggle
======
Toggle a button on and off.
Import
------
Import the Toggle primitives from `ng-primitives/toggle`.
import { NgpToggle } from 'ng-primitives/toggle';
Usage
-----
Assemble the toggle directives in your template.
Toggle
Reusable Component
------------------
Create a reusable component that uses the toggle directives.
Schematics
----------
Generate a reusable toggle component using the Angular CLI.
ng g ng-primitives:primitive toggle
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toggle` package:
### NgpToggle
Apply the `ngpToggle` directive to an element to manage the toggle state. This must be applied to a `button` element.
* Selector: `[ngpToggle]`
* Exported As: `ngpToggle`
Define the selected state. Define the disabled state. Event emitted when the selected state changes.
#### Data Attributes
The following data attributes are applied to the `ngpToggle` directive:
| Attribute | Description |
| --- | --- |
| `data-selected` | Applied when the toggle is selected. |
| `data-disabled` | Applied when the toggle is disabled. |
Accessibility
-------------
### Keyboard Interaction
* Space: Toggles the selected state.
* Enter: Toggles the selected state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toast
=====
A toast is a non-modal, unobtrusive window element used to display brief, auto-expiring messages to the user.
Import
------
Import the Toast primitives from `ng-primitives/toast`.
import { NgpToast } from 'ng-primitives/toast';
Usage
-----
Assemble the toast directives in your template.
Show Toast
...
To show a toast, call the `show` method on the `ngpToast` directive.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toast` package:
The duration in milliseconds that the toast will be visible. The position of the toast. The gravity of the toast. This will determine the location the toast will slide in and out. Whether the toast should stop the timer when hovered over. Once the mouse leaves the toast, the timer will restart. The \`aria-live\` attribute value for the toast. This will determine how the toast will be read by screen readers.
### NgpToast
* Selector: `[ngpToast]`
* Exported As: `ngpToast`
#### Data Attributes
The following data attributes are applied to the first child of the `ngpToast` ng-template:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-toast` | The visible state of the toast. | `visible` \| `hidden` |
| `data-position` | The position of the toast. | `start` \| `center` \| `end` |
| `data-gravity` | The gravity of the toast. | `top` \| `bottom` |
Global Configuration
--------------------
You can configure the default options for all toasts in your application by using the `provideToastConfig` function in a providers array.
import { provideToastConfig } from 'ng-primitives/toast';
bootstrapApplication(AppComponent, {
providers: [\
provideToastConfig({\
duration: 5000,\
position: 'center',\
gravity: 'top',\
stopOnHover: false,\
ariaLive: 'assertive',\
gap: 16,\
}),\
],
});
### NgpToastConfig
The duration in milliseconds that the toast will be visible. The position of the toast. The gravity of the toast. This will determine the location the toast will slide in and out. Whether the toast should stop the timer when hovered over. Once the mouse leaves the toast, the timer will restart. The \`aria-live\` attribute value for the toast. This will determine how the toast will be read by screen readers. The gap between each toast.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Textarea
========
The textarea primitive can be used to enhance the accessibility of a textarea element and provide consistent interaction handling for hover, focus and press states.
Import
------
Import the Textarea primitives from `ng-primitives/textarea`.
import { NgpTextarea } from 'ng-primitives/textarea';
Usage
-----
Assemble the textarea directives in your template.
Reusable Component
------------------
Create an textarea component that uses the `NgpTextarea` directive.
Schematics
----------
Generate a reusable textarea component using the Angular CLI.
ng g ng-primitives:primitive textarea
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Textarea primitive.
### Textarea Form Field
The textarea automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/textarea` package:
### NgpTextarea
* Selector: `[ngpTextarea]`
* Exported As: `ngpTextarea`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocus](/interactions/focus)
, [NgpPress](/interactions/press)
#### Data Attributes
The following data attributes are applied to the `ngpTextarea` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the element is hovered. |
| `data-focus` | Applied when the element is focused. |
| `data-disabled` | Applied when the element is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Switch
======
Perform state toggling.
Import
------
Import the Switch primitives from `ng-primitives/switch`.
import { NgpSwitch, NgpSwitchThumb } from 'ng-primitives/switch';
Usage
-----
Assemble the switch directives in your template.
Reusable Component
------------------
Create a reusable component that uses the switch directives.
Schematics
----------
Generate a reusable switch component using the Angular CLI.
ng g ng-primitives:primitive switch
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Switch primitives.
### Switch Form Field
The switch automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/switch` package:
### NgpSwitch
Apply the `ngpSwitch` directive to an element to manage the checked state.
* Selector: `[ngpSwitch]`
* Exported As: `ngpSwitch`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the checked state. Define the disabled state. Event emitted when the state changes.
#### Data Attributes
The following data attributes are applied to the `ngpSwitch` directive:
| Attribute | Description |
| --- | --- |
| `data-checked` | Applied when the switch is checked. |
| `data-disabled` | Applied when the switch is disabled. |
| `data-hover` | Applied when the switch is hovered. |
| `data-focus-visible` | Applied when the switch is focused. |
| `data-press` | Applied when the switch is pressed. |
### NgpSwitchThumb
Apply the `ngpSwitchThumb` directive to an element within a switch to represent the thumb.
* Selector: `[ngpSwitchThumb]`
* Exported As: `ngpSwitchThumb`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
#### Data Attributes
The following data attributes are available to style the thumb:
| Attribute | Description |
| --- | --- |
| `data-checked` | Applied when the switch is checked. |
| `data-disabled` | Applied when the switch is disabled. |
| `data-hover` | Applied when the switch thumb is hovered. |
| `data-focus-visible` | Applied when the switch thumb is focused. |
| `data-press` | Applied when the switch thumb is pressed. |
Accessibility
-------------
Adheres to the [WAI-ARIA switch design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/)
.
### Keyboard Interactions
* Space - Toggle the switch state.
* Enter - Toggle the switch state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toggle Group
============
The toggle group primitive is a collection of toggle buttons that can be used to select one or more options.
Import
------
Import the ToggleGroup primitives from `ng-primitives/toggle-group`.
import { NgpToggleGroup, NgpToggleGroupItem } from 'ng-primitives/toggle-group';
Usage
-----
Assemble the toggle-group directives in your template.
Option 1
Option 2
Option 3
Reusable Component
------------------
Create a reusable component that uses the toggle group directives.
Schematics
----------
Generate a reusable toggle group component using the Angular CLI.
ng g ng-primitives:primitive toggle-group
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Toggle Group primitives.
### Multiple Selection
The toggle group can be configured to allow multiple selections by setting the `ngpToggleGroupType` input to `multiple`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toggle-group` package:
### NgpToggleGroup
* Selector: `[ngpToggleGroup]`
* Exported As: `ngpToggleGroup`
The orientation of the toggle group. he selected value(s) of the toggle group. The type of the toggle group, whether only one item can be selected or multiple. Whether the toggle group is disabled.
#### Data Attributes
The following data attributes are available to style the toggle group:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the toggle group is disabled. | `-` |
| `data-orientation` | The orientation of the toggle group. | `horizontal` \| `vertical` |
| `data-type` | The type of the toggle group. | `single` \| `multiple` |
### NgpToggleGroupItem
* Selector: `[ngpToggleGroupItem]`
* Exported As: `ngpToggleGroupItem`
The value of the toggle group item. Whether the toggle group item is disabled.
#### Data Attributes
The following data attributes are available to style the toggle group item:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the toggle group item is disabled. | `-` |
| `data-selected` | Applied when the toggle group item is selected. | `-` |
Global Configuration
--------------------
You can configure the default options for all toggle-groups in your application by using the `provideToggleGroupConfig` function in a providers array.
import { provideToggleGroupConfig } from 'ng-primitives/toggle-group';
bootstrapApplication(AppComponent, {
providers: [\
provideToggleGroupConfig({\
orientation: 'vertical',\
type: 'multiple',\
}),\
],
});
### NgpToggleGroupConfig
The default orientation of the toggle group. The default type of the toggle group.
### Keyboard Interaction
* Tab - Moves focus to the first toggle group item in the toolbar.
* Arrow Down - Moves focus to the next toggle group item (vertical orientation).
* Arrow Up - Moves focus to the previous toggle group item (vertical orientation).
* Arrow Right - Moves focus to the next toggle group item (horizontal orientation).
* Arrow Left - Moves focus to the previous toggle group item (horizontal orientation).
* Home - Moves focus to the first toggle group item.
* End - Moves focus to the last toggle group item.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Tabs
====
Dynamically show and hide content based on an active tab.
Import
------
Import the Tabs primitives from `ng-primitives/tabs`.
import { NgpTabset, NgpTabList, NgpTabButton, NgpTabPanel } from 'ng-primitives/tabs';
Usage
-----
Assemble the tabs directives in your template.
Tab 1
Tab 2
Tab 3
Tab 1 content
Tab 2 content
Tab 3 content
Reusable Component
------------------
Create reusable components that uses the tab directives.
Schematics
----------
Generate a reusable tab components using the Angular CLI.
ng g ng-primitives:primitive tabs
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/tabs` package:
### NgpTabset
Apply the `ngpTabset` directive to an element to manage the tabs.
* Selector: `[ngpTabset]`
* Exported As: `ngpTabset`
* Host Directives: [NgpRovingFocusGroup](/primitives/roving-focus)
Define the selected tab. Define the orientation of the tabs. Define whether the tab should activate on focus.
#### Data Attributes
The following data attributes are applied to the `ngpTabset` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
### NgpTabList
Apply the `ngpTabList` directive to an element that represents the list of tab buttons.
* Selector: `[ngpTabList]`
* Exported As: `ngpTabList`
#### Data Attributes
The following data attributes are applied to the `ngpTabList` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
### NgpTabButton
Apply the `ngpTabButton` directive to an element within a tab list to represent a tab button. This directive should be applied to a button element.
* Selector: `[ngpTabButton]`
* Exported As: `ngpTabButton`
* Host Directives: [NgpRovingFocusItem](/primitives/roving-focus)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the value of the tab. Define whether the tab button is disabled.
#### Data Attributes
The following data attributes are applied to the `ngpTabButton` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
| `data-active` | Applied when the tab is active. | `-` |
| `data-disabled` | Applied when the tab is disabled. | `-` |
| `data-hover` | Applied when the tab is hovered. | `-` |
| `data-focus-visible` | Applied when the tab is focused. | `-` |
| `data-press` | Applied when the tab is pressed. | `-` |
### NgpTabPanel
Apply the `ngpTabPanel` directive to an element that represents the content of a tab.
* Selector: `[ngpTabPanel]`
* Exported As: `ngpTabPanel`
Define the value of the tab.
#### Data Attributes
The following data attributes are applied to the `ngpTabPanel` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-active` | Applied when the tab is active. | `-` |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
Global Configuration
--------------------
You can configure the default options for all tabs in your application by using the `provideTabsConfig` function in a providers array.
import { provideTabsConfig } from 'ng-primitives/tabs';
bootstrapApplication(AppComponent, {
providers: [\
provideTabsConfig({\
orientation: 'horizontal',\
activateOnFocus: false,\
wrap: false,\
}),\
],
});
### NgpTabsConfig
The following options are available to configure the default tab options:
Define the default orientation of the tabs. Define whether the tab should activate on focus. Define whether the tabs should wrap around the tab list.
Accessibility
-------------
Adheres to the [Tabs WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs)
.
### Keyboard Interactions
* ArrowLeft: Move focus to the previous tab (horizontal orientation).
* ArrowRight: Move focus to the next tab (horizontal orientation).
* ArrowUp: Move focus to the previous tab (vertical orientation).
* ArrowDown: Move focus to the next tab (vertical orientation).
* Home: Move focus to the first tab.
* End: Move focus to the last tab.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Autofill
========
Detect autofill events on input elements. This can be useful for styling or behavior changes when the browser autofills an input. Floating labels are a common use case for this directive.
Import
------
Import the Autofill primitives from `ng-primitives/autofill`.
import { NgpAutofill } from 'ng-primitives/autofill';
Usage
-----
Assemble the autofill directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/autofill` package:
### NgpAutofill
* Selector: `[ngpAutofill]`
* Exported As: `ngpAutofill`
Event emitted when the autofill state changes.
#### Data Attributes
The following data attributes are applied to the `ngpAutofill` directive:
| Attribute | Description |
| --- | --- |
| `data-autofill` | Applied when the element is autofilled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Separator
=========
The separator primitive allow you to semantically separate content either horizontally or vertically.
Import
------
Import the Separator primitives from `ng-primitives/separator`.
import { NgpSeparator } from 'ng-primitives/separator';
Usage
-----
Assemble the separator directives in your template.
Reusable Component
------------------
Create a reusable component that uses the `NgpSeparator` directive.
Schematics
----------
Generate a reusable separator component using the Angular CLI.
ng g ng-primitives:primitive separator
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/separator` package:
### NgpSeparator
* Selector: `[ngpSeparator]`
* Exported As: `ngpSeparator`
The orientation of the separator.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-orientation` | The orientation of the separator. |
Global Configuration
--------------------
You can configure the default options for all separators in your application by using the `provideSeparatorConfig` function in a providers array.
import { provideSeparatorConfig } from 'ng-primitives/tabs';
bootstrapApplication(AppComponent, {
providers: [\
provideSeparatorConfig({\
orientation: 'horizontal',\
}),\
],
});
### NgpSeparatorConfig
The following options are available to configure the default tab options:
Define the default orientation of the separator. Accessibility
Adheres to the [WAI-ARIA Separator Design Pattern](https://www.w3.org/TR/wai-aria-1.2/#separator)
.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Select
======
A select is a form control that allows users to select options from a list. This primitive enhances the native select element with improved accessibility and interaction handling for hover and focus.
Import
------
Import the Select primitives from `ng-primitives/select`.
import { NgpSelect } from 'ng-primitives/select';
Usage
-----
Assemble the select directives in your template.
24 hours
12 hours
Examples
--------
Here are some additional examples of how to use the Select primitives.
### Select Form Field
The select automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/select` package:
### NgpSelect
Apply the `ngpSelect` directive to a select element that you want to enhance.
* Selector: `[ngpSelect]`
* Exported As: `ngpSelect`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the disabled state.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the element is hovered. |
| `data-focus-visible` | Applied when the element is focused. |
| `data-disabled` | Applied when the element is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
The search primitive is a form control that allows users to enter a search query and clear the input.
Import
------
Import the Search primitives from `ng-primitives/search`.
import { NgpSearch, NgpSearchClear } from 'ng-primitives/search';
Usage
-----
Assemble the search directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/search` package:
### NgpSearch
The `NgpSearch` directive is a container for the search field components.
* Selector: `[ngpSearch]`
* Exported As: `ngpSearch`
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-empty` | Applied when the input is empty. |
### NgpSearchClear
The `NgpSearchClear` directive is can be added to a button to clear the search field on click.
* Selector: `[ngpSearchClear]`
* Exported As: `ngpSearchClear`
| Attribute | Description |
| --- | --- |
| `data-empty` | Applied when the search field is empty. |
Accessibility
-------------
Adheres to the [Search WAI-ARIA design pattern](https://www.w3.org/TR/wai-aria-1.2/#searchbox)
.
### Keyboard Interaction
* Esc - Clears the search field.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Progress
========
Display an indicator representing the progress of a task.
Import
------
Import the Progress primitives from `ng-primitives/progress`.
import { NgpProgress, NgpProgressIndicator } from 'ng-primitives/progress';
Usage
-----
Assemble the avatar directives in your template.
Reusable Component
------------------
Create a reusable component that uses the progress directives.
Schematics
----------
Generate a reusable progress component using the Angular CLI.
ng g ng-primitives:primitive progress
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/progress` package:
### NgpProgress
Apply the `ngpProgress` directive to an element that represents the progress bar.
* Selector: `[ngpProgress]`
* Exported As: `ngpProgress`
Define the progress value. Define the progress max value. Define a function that returns the progress value label.
### NgpProgressIndicator
Apply the `ngpProgressIndicator` directive to an element that represents the current progress. The width of this element can be set to the percentage of the progress value.
* Selector: `[ngpProgressIndicator]`
* Exported As: `ngpProgressIndicator`
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Resize
======
Perform actions on element resize.
Import
------
Import the Resize primitive from `ng-primitives/resize`.
import { NgpResize } from 'ng-primitives/resize';
Usage
-----
Assemble the resize directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/resize` package:
### NgpResize
Apply the `ngpResize` directive to an element to listen for resize events.
* Selector: `[ngpResize]`
* Exported As: `ngpResize`
Event emitted when the element is resize.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Popover
=======
Display arbitrary content inside floating panels.
Import
------
Import the Popover primitives from `ng-primitives/popover`.
import { NgpPopover } from 'ng-primitives/popover';
Usage
-----
Assemble the popover directives in your template.
Click me
Popover content
API Reference
-------------
The following directives are available to import from the `ng-primitives/popover` package:
### NgpPopover
Apply the `ngpPopover` directive to an element that represents the popover. This typically would be a `div` inside an `ng-template`.
* Selector: `[ngpPopover]`
* Exported As: `ngpPopover`
### NgpPopoverTrigger
Apply the `ngpPopoverTrigger` directive to an element that triggers the popover to show.
* Selector: `[ngpPopoverTrigger]`
* Exported As: `ngpPopoverTrigger`
Define the content of the popover. This should be reference to an \`ng-template\`. Define the open state. Event emitted when the state changes. Define the offset from the trigger element. Define the disabled state. Define the placement of the popover. Define the delay before the popover shows. Define the delay before the popover hides. Define if the popover should flip when it reaches the edge of the viewport. Define the container element for the popover. This is the document body by default. Define whether the popover should close when clicking outside of it. Defines how the popover behaves when the window is scrolled. If set to \`reposition\`, the popover will adjust its position automatically during scrolling. Make sure the popover uses \`position: absolute\` in this mode. If set to \`block\`, scrolling will be disabled while the popover is open. In this case, the popover should use \`position: fixed\`.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-open` | Applied when the popover is open. |
| `data-disabled` | Applied when the popover is disabled. |
Global Configuration
--------------------
You can configure the default options for all popovers in your application by using the `providePopoverConfig` function in a providers array.
import { providePopoverConfig } from 'ng-primitives/popover';
bootstrapApplication(AppComponent, {
providers: [\
providePopoverConfig({\
offset: 4,\
placement: 'top',\
showDelay: 0,\
hideDelay: 0,\
flip: true,\
container: document.body,\
closeOnOutsideClick: true,\
scrollBehavior: 'reposition',\
}),\
],
});
### NgpPopoverConfig
Define the offset from the trigger element. Define the placement of the popover. Define the delay before the popover shows. Define the delay before the popover hides. Define if the popover should flip when it reaches the edge of the viewport. Define the container element for the popover. This is the document body by default. Define whether the popover should close when clicking outside of it. Defines how the popover behaves when the window is scrolled. If set to \`reposition\`, the popover will adjust its position automatically during scrolling. Make sure the popover uses \`position: absolute\` in this mode. If set to \`block\`, scrolling will be disabled while the popover is open. In this case, the popover should use \`position: fixed\`.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Roving Focus
============
Handle focus for a group of elements.
Import
------
Import the Roving Focus primitives from `ng-primitives/roving-focus`.
import { NgpRovingFocusGroup, NgpRovingFocusItem } from 'ng-primitives/roving-focus';
Usage
-----
Assemble the roving focus directives in your template.
Item 1
Item 2
Item 3
API Reference
-------------
The following directives are available to import from the `ng-primitives/roving-focus` package:
### NgpRovingFocusGroup
Apply the `ngpRovingFocusGroup` directive to an element to manage focus for a group of child elements.
* Selector: `[ngpRovingFocusGroup]`
* Exported As: `ngpRovingFocusGroup`
Define the orientation of the roving focus group. Define whether the focus should wrap around the group. Define whether the focus should move to the first or last element when pressing the Home or End key. Define whether the roving focus group is disabled.
### NgpRovingFocusItem
Apply the `ngpRovingFocusItem` directive to an element within a roving focus group to automatically manage focus.
* Selector: `[ngpRovingFocusItem]`
* Exported As: `ngpRovingFocusItem`
Define whether the roving focus item is disabled.
Accessibility
-------------
Adheres to the [WAI-ARIA Keyboard Interface Practices](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/)
.
### Keyboard Interactions
* Tab - Move focus to the first item.
* ArrowLeft - Move focus to the previous item (horizontal orientation).
* ArrowUp - Move focus to the previous item (vertical orientation).
* ArrowRight - Move focus to the next item (horizontal orientation).
* ArrowDown - Move focus to the next item (vertical orientation).
* Home - Move focus to the first item.
* End - Move focus to the last item.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Pagination
==========
The Pagination primitives provide a set of directives to create a pagination control. The pagination control is used to navigate through a set of data that is split into multiple pages.
Import
------
Import the Pagination primitives from `ng-primitives/pagination`.
import {
NgpPagination,
NgpPaginationButton,
NgpPaginationFirst,
NgpPaginationNext,
NgpPaginationPrevious,
NgpPaginationLast,
} from 'ng-primitives/pagination';
Usage
-----
Assemble the pagination directives in your template.
Reusable Component
------------------
Create a reusable component that uses the pagination directives.
Schematics
----------
Generate a reusable pagination component using the Angular CLI.
ng g ng-primitives:primitive pagination
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/pagination` package:
### NgpPagination
The `NgpPagination` directive is used to create a pagination control.
* Selector: `[ngpPagination]`
* Exported As: `ngpPagination`
The current page number. The total number of pages. Emits the new page number when the page changes. Disables the pagination control.
#### Data Attributes
The following data attributes are applied to the `ngpPagination` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-page` | The current page number. | `number` |
| `data-page-count` | The total number of pages. | `number` |
| `data-disabled` | Disables the pagination control. | `boolean` |
| `data-first-page` | Whether the current page is the first page. | `boolean` |
| `data-last-page` | Whether the current page is the last page. | `boolean` |
### NgpPaginationButton
The `NgpPaginationButton` directive is used to create a pagination button.
* Selector: `[ngpPaginationButton]`
* Exported As: `ngpPaginationButton`
* Host Directives: [NgpButton](/primitives/button)
The page number that the button navigates to. Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationButton` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-page` | The page number that the button navigates to. | `number` |
| `data-selected` | Applied when the button is selected. | `-` |
| `data-hover` | Applied when the button is hovered. | `-` |
| `data-focus-visible` | Applied when the button is focused. | `-` |
| `data-press` | Applied when the button is pressed. | `-` |
| `data-disabled` | Disables the pagination button. | `-` |
### NgpPaginationFirst
The `NgpPaginationFirst` directive is used to create a pagination button that navigates to the first page.
* Selector: `[ngpPaginationFirst]`
* Exported As: `ngpPaginationFirst`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationFirst` directive:
| Attribute | Description |
| --- | --- |
| `data-first-page` | Applied when the current page is the first page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpPaginationPrevious
The `NgpPaginationPrevious` directive is used to create a pagination button that navigates to the previous page.
* Selector: `[ngpPaginationPrevious]`
* Exported As: `ngpPaginationPrevious`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationPrevious` directive:
| Attribute | Description |
| --- | --- |
| `data-first-page` | Applied when the current page is the first page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpPaginationNext
The `NgpPaginationNext` directive is used to create a pagination button that navigates to the next page.
* Selector: `[ngpPaginationNext]`
* Exported As: `ngpPaginationNext`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationNext` directive:
| Attribute | Description |
| --- | --- |
| `data-last-page` | Applied when the current page is the last page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpPaginationLast
The `NgpPaginationLast` directive is used to create a pagination button that navigates to the last page.
* Selector: `[ngpPaginationLast]`
* Exported As: `ngpPaginationLast`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationLast` directive:
| Attribute | Description |
| --- | --- |
| `data-last-page` | Applied when the current page is the last page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Icons
=====
Enhance your application by providing a visually appealing and intuitive way to represent actions, statuses, and features. Icons improve user experience, aid in navigation, and help convey information quickly.
We also maintain the popular [Angular Icons library](https://ng-icons.github.io/ng-icons)
which gives you access to over 50,000 icons from popular icon libraries like Font Awesome, Material Design, Heroicons and more.
Import
------
The `NgIcon` component is used to render icons in your application. To use icons, you need to import the `NgIcon` directive from `@ng-icons/core`.
Icons must be registered using the `provideIcons` function. The icons you want to use must be individually imported from their respective packages.
import { NgIcon, provideIcons } from '@ng-icons/core';
import { featherAirplay } from '@ng-icons/feather-icons';
import { heroUsers } from '@ng-icons/heroicons/outline';
@Component({
selector: 'app-root',
template: `
`,
imports: [NgIcon],
viewProviders: [provideIcons({ featherAirplay, heroUsers })],
})
export class AppComponent {}
View the full list of available icons in the [Angular Icons documentation](https://ng-icons.github.io/ng-icons/#/browse-icons)
.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Listbox
=======
A listbox presents a set of choices and lets users select one or multiple options. It can be paired with the `NgpPopover` directive to create a dropdown listbox.
Import
------
Import the Listbox primitives from `ng-primitives/listbox`.
import { NgpListbox } from 'ng-primitives/listbox';
Usage
-----
Assemble the listbox directives in your template.
Option 1
Option 2
Option 3
Reusable Component
------------------
Create a reusable component that uses the listbox directives.
Schematics
----------
Generate a reusable listbox component using the Angular CLI.
ng g ng-primitives:primitive listbox
### Options
* `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`.
Examples
--------
### Single-Select Listbox
The listbox can be configured to allow a single selection.
### Multi-Select Listbox
The listbox can be configured to allow multiple selections.
### Listbox with Sections
The listbox can be configured to have sections and headers.
API Reference
-------------
The following directives are available to import from the `ng-primitives/listbox` package:
### NgpListbox
* Selector: `[ngpListbox]`
* Exported As: `ngpListbox`
The selection mode of the listbox. Can be either \`single\` or \`multiple\`. The selected value(s) of the listbox. Whether the listbox is disabled. A function to compare two values of the listbox. The function should return \`true\` if the values are equal. This is useful when the listbox options are objects.
#### Data Attributes
The following data attributes are applied to the `ngpListbox` directive:
| Attribute | Description |
| --- | --- |
| `data-focus-visible` | Applied to the listbox when focused via the keyboard. |
### NgpListboxOption
* Selector: `[ngpListboxOption]`
* Exported As: `ngpListboxOption`
The value of the option. Whether the option is disabled.
#### Data Attributes
The following data attributes are applied to the `ngpListboxOption` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied to the listbox option when hovered. |
| `data-focus` | Applied to the listbox option when focused. |
| `data-focus-visible` | Applied to the listbox option when focused via the keyboard. |
| `data-disabled` | Applied to the listbox option when disabled. |
| `data-active` | Applied to the listbox option when it is the active descendant. |
| `data-disabled` | Applied to the listbox option when it is disabled. |
| `data-selected` | Applied to the listbox option when it is selected. |
### NgpListboxSection
* Selector: `[ngpListboxSection]`
* Exported As: `ngpListboxSection`
### NgpListboxTrigger
* Selector: `[ngpListboxTrigger]`
* Exported As: `ngpListboxTrigger`
Augments the popover trigger with listbox-specific behavior, such as opening the listbox when the arrow keys are pressed.
Accessibility
-------------
Adheres to the [WAI-ARIA Listbox Design Pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#Listbox)
.
### Keyboard Interactions
* Arrow Down - Move focus to the next option.
* Arrow Up - Move focus to the previous option.
* Home - Move focus to the first option.
* End - Move focus to the last option.
* Space - Select the focused option.
* Enter - Select the focused option.
* Escape - Close the listbox.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Radio
=====
Selection within a group.
Import
------
Import the Radio primitives from `ng-primitives/radio`.
import { NgpRadioGroup, NgpRadioItem, NgpRadioIndicator } from 'ng-primitives/radio';
Usage
-----
Assemble the radio directives in your template.
Option 1
Option 2
Option 3
Reusable Component
------------------
Create a reusable component that uses the radio directives.
Schematics
----------
Generate a reusable radio component using the Angular CLI.
ng g ng-primitives:primitive radio
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/radio` package:
### NgpRadioGroup
Apply the `ngpRadioGroup` directive to an element that represents the group of radio items.
* Selector: `[ngpRadioGroup]`
* Exported As: `ngpRadioGroup`
* Host Directives: [NgpRovingFocusGroup](/primitives/roving-focus)
, [NgpFormControl](/primitives/form-field)
Define the selected value. Define the disabled state.
Define the orientation.
Event emitted when the selection changes.
### NgpRadioItem
Apply the `ngpRadioItem` directive to an element that represents a radio item. This would typically be a `button` element.
* Selector: `[ngpRadioItem]`
* Exported As: `ngpRadioItem`
* Host Directives: [NgpRovingFocusItem](/primitives/roving-focus)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the value of this item. Define the disabled state.
#### Data Attributes
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. | `-` |
#### Data Attributes
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. |
### NgpRadioIndicator
Apply the `ngpRadioIndicator` directive to an element that represents the radio indicator (i.e. the dot).
* Selector: `[ngpRadioIndicator]`
* Exported As: `ngpRadioIndicator`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpPress](/interactions/press)
#### Data Attributes
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. |
Accessibility
-------------
Adheres to the [Radio Group WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radio)
.
### Keyboard Interaction
* Tab - Moves focus to the first radio button.
* Arrow Down - Moves focus to the next radio button (vertical orientation).
* Arrow Up - Moves focus to the previous radio button (vertical orientation).
* Arrow Right - Moves focus to the next radio button (horizontal orientation).
* Arrow Left - Moves focus to the previous radio button (horizontal orientation).
* Space - Selects the focused radio button if not already selected.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Menu
====
A menu is a list of options or commands presented to the user in a dropdown list.
Import
------
Import the Menu primitives from `ng-primitives/menu`.
import { NgpMenu, NgpMenuItem, NgpMenuTrigger, NgpSubmenuTrigger } from 'ng-primitives/menu';
Usage
-----
Assemble the menu directives in your template.
Examples
--------
Here are some additional examples of how to use the Menu primitives.
### Submenu
The menu can contain submenus, which are nested menus that can be opened by hovering on a menu item.
API Reference
-------------
The following directives are available to import from the `ng-primitives/menu` package:
### NgpMenuTrigger
The `NgpMenuTrigger` directive allows you to turn an element into a menu trigger.
* Selector: `[ngpMenuTrigger]`
* Exported As: `ngpMenuTrigger`
The menu template to display when the trigger is activated.
#### Data Attributes
The following data attributes are available on the `NgpMenuTrigger` directive:
| Attribute | Description |
| --- | --- |
| `data-open` | Applied when the menu is open. |
### NgpMenu
The `NgpMenu` is a container for menu items.
* Selector: `[ngpMenu]`
* Exported As: `ngpMenu`
### NgpMenuItem
The `NgpMenuItem` directive represents a menu item.
* Selector: `[ngpMenuItem]`
* Exported As: `ngpMenuItem`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define if the menu item is disabled.
#### Data Attributes
The following data attributes are available on the `NgpMenuItem` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the item is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Form Field
==========
Import
------
Import the FormField primitives from `ng-primitives/form-field`.
import {
NgpFormField,
NgpLabel,
NgpDescription,
NgpError,
NgpFormControl,
} from 'ng-primitives/form-field';
Usage
-----
Assemble the form-field directives in your template.
Reusable Component
------------------
Create a reusable component that uses the `NgpFormField` directive.
Schematics
----------
Generate a reusable form-field component using the Angular CLI.
ng g ng-primitives:primitive form-field
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/form-field` package:
### NgpFormField
The `NgpFormField` directive is a container for form field elements. Any labels, form controls, or descriptions should be placed within this directive.
* Selector: `[ngpFormField]`
* Exported As: `ngpFormField`
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-invalid` | Applied when the form control is invalid. |
| `data-valid` | Applied when the form control is valid. |
| `data-touched` | Applied when the form control is touched. |
| `data-pristine` | Applied when the form control is pristine. |
| `data-dirty` | Applied when the form control is dirty. |
| `data-pending` | Applied when the form control is pending. |
| `data-disabled` | Applied when the form control is disabled. |
### NgpLabel
The `NgpLabel` directive is used to mark a label element within a form field. Preferably, there should use an HTML `` element.
* Selector: `[ngpLabel]`
* Exported As: `ngpLabel`
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-invalid` | Applied when the form control is invalid. | |
| `data-valid` | Applied when the form control is valid. | |
| `data-touched` | Applied when the form control is touched. | |
| `data-pristine` | Applied when the form control is pristine. | |
| `data-dirty` | Applied when the form control is dirty. | |
| `data-pending` | Applied when the form control is pending. | |
| `data-disabled` | Applied when the form control is disabled. | |
### NgpDescription
The `NgpDescription` directive is used to mark a description element within a form field. There may be multiple descriptions associated with a form control.
* Selector: `[ngpDescription]`
* Exported As: `ngpDescription`
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-invalid` | Applied when the form control is invalid. | |
| `data-valid` | Applied when the form control is valid. | |
| `data-touched` | Applied when the form control is touched. | |
| `data-pristine` | Applied when the form control is pristine. | |
| `data-dirty` | Applied when the form control is dirty. | |
| `data-pending` | Applied when the form control is pending. | |
| `data-disabled` | Applied when the form control is disabled. | |
### NgpError
The `NgpError` directive is used to mark an error message element within a form field. There may be multiple error messages associated with a form control.
* Selector: `[ngpError]`
* Exported As: `ngpError`
The name of the validator associated with this error message.
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-validator` | Whether the validator specified in `ngpErrorValidator` is failing. | `fail` \| `pass` |
| `data-invalid` | Applied when the form control is invalid. | `-` |
| `data-valid` | Applied when the form control is valid. | `-` |
| `data-touched` | Applied when the form control is touched. | `-` |
| `data-pristine` | Applied when the form control is pristine. | `-` |
| `data-dirty` | Applied when the form control is dirty. | `-` |
| `data-pending` | Applied when the form control is pending. | `-` |
| `data-disabled` | Applied when the form control is disabled. | `-` |
### NgpFormControl
Typically this primitive would be not be used directly, but instead a more specific form control primitive would be used (e.g. `ngpInput`). All of our form control primitives use `ngpFormControl` internally so they will have the same accessibility features as described below.
The `NgpFormControl` directive is used to mark a form control element within a form field. This element will have an `aria-labelledby` attribute set to the ID of the label element within the form field and an `aria-describedby` attribute set to the ID of the description elements within the form field.
* Selector: `[ngpFormControl]`
* Exported As: `ngpFormControl`
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-invalid` | Applied when the form control is invalid. | |
| `data-valid` | Applied when the form control is valid. | |
| `data-touched` | Applied when the form control is touched. | |
| `data-pristine` | Applied when the form control is pristine. | |
| `data-dirty` | Applied when the form control is dirty. | |
| `data-pending` | Applied when the form control is pending. | |
| `data-disabled` | Applied when the form control is disabled. | |
Accessibility
-------------
The label and description elements should be associated with the form control using the `aria-labelledby` and `aria-describedby` attributes, respectively. This will ensure that screen readers can provide the necessary context to users.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Input
=====
The input primitive can be used to enhance the accessibility of an input element and provide consistent interaction handling for hover, focus, press and autofill states.
Import
------
Import the Input primitives from `ng-primitives/input`.
import { NgpInput } from 'ng-primitives/input';
Usage
-----
Assemble the input directives in your template.
Reusable Component
------------------
Create an input component that uses the `NgpInput` directive.
Schematics
----------
Generate a reusable input component using the Angular CLI.
ng g ng-primitives:primitive input
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Input primitive.
### Input Form Field
The input automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/input` package:
### NgpInput
* Selector: `[ngpInput]`
* Exported As: `ngpInput`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocus](/interactions/focus)
, [NgpPress](/interactions/press)
, [NgpAutofill](/utilities/autofill)
#### Data Attributes
The following data attributes are applied to the `ngpInput` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied to the input when hovered. |
| `data-focus` | Applied to the input when focused. |
| `data-disabled` | Applied to the input when disabled. |
| `data-autofill` | Applied to the input when autofilled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Checkbox
========
Perform state toggling.
Import
------
Import the Checkbox primitives from `ng-primitives/checkbox`.
import { NgpCheckbox } from 'ng-primitives/checkbox';
Usage
-----
Assemble the checkbox directives in your template.
Reusable Component
------------------
Create a reusable component that uses the `NgpCheckbox` directive.
Schematics
----------
Generate a reusable checkbox component using the Angular CLI.
ng g ng-primitives:primitive checkbox
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Checkbox primitives.
### Checkbox Form Field
The checkbox automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/checkbox` package:
### NgpCheckbox
Apply the `ngpCheckbox` directive to an element to that represents the checkbox, such as a `button`.
* Selector: `[ngpCheckbox]`
* Exported As: `ngpCheckbox`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the checked state. Define the interminate state. Define the disabled state. Event emitted when the state changes. Event emitted when the indeterminate state changes.
| 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. |
Accessibility
-------------
Adheres to the [Tri-State Checkbox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox)
.
### Keyboard Interactions
* Space - Toggle the checked state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
File Upload
===========
The file upload primitive allows you to trigger a file upload from any element, giving you the more control over the appearance and behavior compared to the native file input.
Import
------
Import the FileUpload primitives from `ng-primitives/file-upload`.
import { NgpFileUpload } from 'ng-primitives/file-upload';
Usage
-----
Assemble the file-upload directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/file-upload` package:
### NgpFileUpload
A directive that allows you to turn any element into a file upload trigger.
* Selector: `[ngpFileUpload]`
* Exported As: `ngpFileUpload`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define if multiple files can be selected. Define the file types that can be selected. Define if directories can be selected. Define if drag and drop is enabled. Define if the file upload is disabled. Event emitted when files are selected. Event emitted when the user cancels the file upload or selects the same file(s) again. Event emitted when a file is dragged over or out of the element.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the element is hovered. |
| `data-focus-visible` | Applied when the element is focus visible. |
| `data-press` | Applied when the element is pressed. |
| `data-dragover` | Applied when a file is dragged over the element. |
| `data-disabled` | Applied when the element is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Avatar
======
Display an image that represents a user with a text fallback.
Import
------
Import the Avatar primitives from `ng-primitives/avatar`.
import { NgpAvatar, NgpAvatarImage, NgpAvatarFallback } from 'ng-primitives/avatar';
Usage
-----
Assemble the avatar directives in your template.
NG
Reusable Component
------------------
Create a reusable component that uses the `NgpAvatar` directive.
Schematics
----------
Generate a reusable avatar component using the Angular CLI.
ng g ng-primitives:primitive avatar
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/avatar` package:
### NgpAvatar
Apply the `ngpAvatar` directive to an element that represents the avatar. This directive is a container for the image and/or fallback.
* Selector: `[ngpAvatar]`
* Exported As: `ngpAvatar`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-status` | The loading status of the avatar image. | `idle` \| `loading` \| `loaded` \| `error` |
| `data-hover` | The added to the avatar when hovered. | `-` |
| `data-focus-visible` | The added to the avatar when focus visible. | `-` |
| `data-press` | The added to the avatar when pressed. | `-` |
### NgpAvatarImage
Apply the `ngpAvatarImage` directive to an element that represents the avatar image. This would typically be an `img` element or a `div` with a background image.
* Selector: `[ngpAvatarImage]`
* Exported As: `ngpAvatarImage`
* Host Directives: [NgpVisuallyHidden](/utilities/visually-hidden)
### NgpAvatarFallback
Apply the `ngpAvatarFallback` directive to an element that represents the user in the absence of an image. This is typically the user's initials.
* Selector: `[ngpAvatarFallback]`
* Exported As: `ngpAvatarFallback`
Define a delay before the fallback is shown. This is useful to only show the fallback for those with slower connections.
Global Configuration
--------------------
You can configure the default options for all avatars in your application by using the `provideAvatarConfig` function in a providers array.
import { provideAvatarConfig } from 'ng-primitives/avatar';
bootstrapApplication(AppComponent, {
providers: [provideAvatarConfig({ delay: 1000 })],
});
### NgpAvatarConfig
Define a delay before the fallback is shown. This is useful to only show the fallback for those with slower connections.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Date Picker
===========
A date picker is a component that allows users to select a date from a calendar and navigate through months and years.
Import
------
Import the DatePicker primitives from `ng-primitives/date-picker`.
import {
NgpDatePicker,
NgpDatePickerLabel,
NgpDatePickerNextMonth,
NgpDatePickerPreviousMonth,
NgpDatePickerGrid,
NgpDatePickerCell,
NgpDatePickerRowRender,
NgpDatePickerCellRender,
NgpDatePickerDateButton,
} from 'ng-primitives/date-picker';
Usage
-----
Assemble the date-picker directives in your template.
Reusable Component
------------------
Create a reusable component that uses the date picker directives.
Schematics
----------
Generate a reusable date-picker component using the Angular CLI.
ng g ng-primitives:primitive date-picker
### Options
* `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`.
API Reference
-------------
By default, the date picker uses the native JavaScript `Date` object, however the date picker is designed to work with any date library. To use a date library, such as Luxon, you need to specify the appropriate date adapter. The date adapter is an abstraction layer that allows components to use date objects from any date library, ensuring compatibility and easy integration. To learn more about the date adapter, see the [Date Adapter](/utilities/date-adapter)
documentation.
The following directives are available to import from the `ng-primitives/date-picker` package:
### NgpDatePicker
The outermost container for the date picker.
* Selector: `[ngpDatePicker]`
* Exported As: `ngpDatePicker`
Define the selected date. The type \`T\` is a generic type that represents the date value which can be a \`Date\` or a custom Date object handled by a \`NgpDateAdapter\`. Define the minimum date that can be selected. Define the maximum date that can be selected. Define the disabled state. Define a function that determines if a date is disabled. The function receives a date value and should return \`true\` if the date is disabled. Define the focused date.
#### Data Attributes
The following data attributes are available on the `ngpDatePicker` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the date picker is disabled. |
### NgpDatePickerLabel
The label that displays the current month and year typically in the header of the date picker. This will be announced by screen readers when the date changes.
* Selector: `[ngpDatePickerLabel]`
* Exported As: `ngpDatePickerLabel`
#### Data Attributes
The following data attributes are available on the `ngpDatePickerLabel` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the date picker is disabled. |
### NgpDatePickerPreviousMonth
A button that navigates to the previous month.
* Selector: `[ngpDatePickerPreviousMonth]`
* Exported As: `ngpDatePickerPreviousMonth`
* Host Directives: [NgpButton](/primitives/button)
#### Data Attributes
The following data attributes are available on the `ngpDatePickerPreviousMonth` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpDatePickerNextMonth
A button that navigates to the next month.
* Selector: `[ngpDatePickerNextMonth]`
* Exported As: `ngpDatePickerNextMonth`
* Host Directives: [NgpButton](/primitives/button)
#### Data Attributes
The following data attributes are available on the `ngpDatePickerNextMonth` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpDatePickerGrid
The grid that contains the days of the month.
* Selector: `[ngpDatePickerGrid]`
* Exported As: `ngpDatePickerGrid`
#### Data Attributes
The following data attributes are available on the `ngpDatePickerGrid` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the date picker is disabled. |
### NgpDatePickerRowRender
A structural directive that renders a row of weekdays in the date picker grid.
* Selector: `*ngpDatePickerRowRender`
* Exported As: `ngpDatePickerRowRender`
### NgpDatePickerCellRender
A structural directive that renders a cell in the date picker grid.
* Selector: `*ngpDatePickerCellRender`
* Exported As: `ngpDatePickerCellRender`
The following context fields are available on the `ngpDatePickerCellRender` directive:
The date value for the cell.
### NgpDatePickerCell
A cell in the date picker grid.
* Selector: `[ngpDatePickerCell]`
* Exported As: `ngpDatePickerCell`
#### Data Attributes
The following data attributes are available on the `ngpDatePickerCell` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the cell is disabled. |
| `data-selected` | Applied when the cell is selected. |
### NgpDatePickerDateButton
A button that represents a date in the date picker grid.
* Selector: `[ngpDatePickerDateButton]`
* Exported As: `ngpDatePickerDateButton`
* Host Directives: [NgpButton](/primitives/button)
#### Data Attributes
The following data attributes are available on the `ngpDatePickerDateButton` directive:
| Attribute | Description |
| --- | --- |
| `data-selected` | Applied when the button is selected. |
| `data-outside-month` | Applied when the button is outside the current month. |
| `data-today` | Applied when the button represents the current date. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
Accessibility
-------------
Adheres to the [WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/)
.
### Keyboard Interactions
* Space - Selects the focused date.
* Enter - Selects the focused date.
* ArrowUp - Moves focus to the same day of the previous week.
* ArrowDown - Moves focus to the same day of the next week.
* ArrowLeft - Moves focus to the previous day.
* ArrowRight - Moves focus to the next day.
* Home - Moves focus to the first day of the month.
* End - Moves focus to the last day of the month.
* PageUp - Moves focus to the same date in the previous month.
* PageDown - Moves focus to the same date in the next month.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Dialog
======
A dialog is a floating window that can be used to display information or prompt the user for input.
Import
------
Import the Dialog primitives from `ng-primitives/dialog`.
import {
NgpDialog,
NgpDialogTitle,
NgpDialogDescription,
NgpDialogTrigger,
NgpDialogOverlay,
} from 'ng-primitives/dialog';
Usage
-----
Assemble the dialog directives in your template.
Launch Dialog
Publish this article?
Are you sure you want to publish this article? This action is irreversible.
API Reference
-------------
The following directives are available to import from the `ng-primitives/dialog` package:
### NgpDialog
The dialog container.
* Selector: `[ngpDialog]`
* Exported As: `ngpDialog`
The role of the dialog. Use \`'dialog'\` for dialogs that require user interaction and \`'alertdialog'\` for dialogs that require immediate user attention. Whether the dialog is modal. A modal dialog prevents the user from interacting with the rest of the page until the dialog is closed.
| Attribute | Description |
| --- | --- |
| `data-closing` | Applied when the dialog is closing. |
### NgpDialogTitle
The dialog title.
* Selector: `[ngpDialogTitle]`
* Exported As: `ngpDialogTitle`
### NgpDialogDescription
The dialog description.
* Selector: `[ngpDialogDescription]`
* Exported As: `ngpDialogDescription`
### NgpDialogTrigger
Add to a button or link to open the dialog.
* Selector: `[ngpDialogTrigger]`
* Exported As: `ngpDialogTrigger`
The dialog template to open when the trigger is activated.
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the trigger is hovered. |
| `data-focus-visible` | Applied when the trigger is focused. |
| `data-press` | Applied when the trigger is pressed. |
| `data-disabled` | Applied when the trigger is disabled. |
### NgpDialogOverlay
The dialog overlay.
* Selector: `[ngpDialogOverlay]`
* Exported As: `ngpDialogOverlay`
| Attribute | Description |
| --- | --- |
| `data-closing` | Applied when the dialog is closing. |
Examples
--------
### Dialog with external data
Data can be passed to the dialog using the `NgpDialogManager`.
### Drawer
A drawer is a type of dialog that slides in from the side of the screen.
Accessibility
-------------
Adheres to the [WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/dialog/)
.
### Keyboard Interactions
* Esc: Close the dialog.
* Tab: Navigate through focusable elements within the dialog.
* Shift + Tab: Navigate backwards through focusable elements within the dialog.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Button
======
A button is a clickable element that can be used to trigger an action. This primitive enhances the native button element with improved accessibility and interaction handling for hover, press and focus.
Import
------
Import the Button primitives from `ng-primitives/button`.
import { NgpButton } from 'ng-primitives/button';
Usage
-----
Assemble the button directives in your template.
Button
Reusable Component
------------------
Create a button component that uses the `NgpButton` directive.
Schematics
----------
Generate a reusable button component using the Angular CLI.
ng g ng-primitives:primitive button
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/button` package:
### NgpButton
A directive that can be used to create a button.
* Selector: `[ngpButton]`
* Exported As: `ngpButton`
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Added to the button when hovered. |
| `data-focus-visible` | Added to the button when focused. |
| `data-press` | Added to the button when pressed. |
| `data-disabled` | Added to the button when disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Accordion
=========
Display a series of panels that can be expanded or collapsed.
Import
------
Import the Accordion primitives from `ng-primitives/accordion`.
import {
NgpAccordion,
NgpAccordionItem,
NgpAccordionTrigger,
NgpAccordionContent,
} from 'ng-primitives/accordion';
Usage
-----
Assemble the accordion directives in your template.
Would you like to learn more?
If you would like to learn more please reach out to us on GitHub.
Can I use this in my project?
Yes, this is open source and you can use it in your project.
Reusable Component
------------------
Create reusable components that uses the `NgpAccordion` and `NgpAccordionItem` directives.
Schematics
----------
Generate a reusable accordion component using the Angular CLI.
ng g ng-primitives:primitive accordion
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/accordion` package:
### NgpAccordion
Apply the `ngpAccordion` directive to an element that represents the group of accordion items.
* Selector: `[ngpAccordion]`
* Exported As: `ngpAccordion`
Define whether only one or multiple accordion items can be open at a time. Define an accordion can be collapsed. This is only applicable when \`ngpAccordionType\` is set to \`single\`. Define the expanded accordion items. This should be a single value when \`ngpAccordionType\` is set to \`single\` and an array when set to \`multiple\`. Define whether the accordion is disabled. Define the orientation of the accordion. Emitted when the expanded accordion items change. This will be a single value when \`ngpAccordionType\` is set to \`single\` and an array when set to \`multiple\`.
#### Data Attributes
The following data attributes are applied to the `ngpAccordion` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-disabled` | Applied when the element is disabled. | `-` |
### NgpAccordionItem
Apply the `ngpAccordionItem` directive to an element that represents an accordion item.
* Selector: `[ngpAccordionItem]`
* Exported As: `ngpAccordionItem`
Define the value of the accordion item. Define whether the accordion item is disabled.
#### Data Attributes
The following data attributes are applied to the `ngpAccordionItem` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-open` | Applied when the accordion item is open. | `-` |
| `data-disabled` | Applied when the accordion item is disabled. | `-` |
### NgpAccordionTrigger
Apply the `ngpAccordionTrigger` directive to an element that represents the trigger for an accordion item, such as a button.
* Selector: `[ngpAccordionTrigger]`
* Exported As: `ngpAccordionTrigger`
#### Data Attributes
The following data attributes are applied to the `ngpAccordionTrigger` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-open` | Applied when the accordion item is open. | `-` |
| `data-disabled` | Applied when the accordion item is disabled. | `-` |
### NgpAccordionContent
Apply the `ngpAccordionContent` directive to an element that represents the content of an accordion item.
* Selector: `[ngpAccordionContent]`
* Exported As: `ngpAccordionContent`
#### Data Attributes
The following data attributes are applied to the `ngpAccordionContent` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-open` | Applied when the accordion item is open. | `-` |
Global Configuration
--------------------
You can configure the default options for all accordions in your application by using the `provideAccordionConfig` function in a providers array.
import { provideAccordionConfig } from 'ng-primitives/accordion';
bootstrapApplication(AppComponent, {
providers: [\
provideAccordionConfig({\
type: 'multiple',\
collapsible: true,\
orientation: 'horizontal',\
}),\
],
});
### NgpAccordionConfig
Define whether only one or multiple accordion items can be open at a time. Define an accordion can be collapsed. This is only applicable when \`type\` is set to \`single\`. Define the orientation of the accordion.
Accessibility
-------------
Adheres to the [Accordion WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion)
.
### Keyboard Interactions
* Space - Toggle the expanded state of the accordion item when the trigger is focused.
* Enter - Toggle the expanded state of the accordion item when the trigger is focused.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Press
=====
Normalizes the press event across different browsers and devices.
Import
------
Import the Press primitives from `ng-primitives/interactions`.
import { NgpPress } from 'ng-primitives/interactions';
Usage
-----
Assemble the press directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpPress
The `ngpPress` directive listens for press events on an element. This is particularly useful for supporting press events on touch devices, where press events are not handled consistently.
* Selector: `[ngpPress]`
* Exported As: `ngpPress`
Event emitted when the press state changes. Whether press events are disabled. Event emitted when the press starts. Event emitted when the press ends.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-press` | Applied when the element is being pressed. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Hover
=====
Normalizes the hover event across different browsers and devices.
Import
------
Import the Hover primitive from `ng-primitives/interactions`.
import { NgpHover } from 'ng-primitives/interactions';
Usage
-----
Assemble the hover directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpHover
* Selector: `[ngpHover]`
* Exported As: `ngpHover`
Apply the `ngpHover` directive to an element that you want to listen for hover events. This is particulaly useful for supporting hover events on touch devices, where hover events are not handled consistently. On iOS relying on the `:hover` pseudo-class can result in the hover state being stuck until the user taps elsewhere on the screen.
Event emitted when the hover state changes. Event emitted when the hover starts. Event emitted when the hover ends. Whether hover events are disabled.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Added to the element when hovering occurs. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Move
====
The Move primitives enable pointer and keyboard move interactions on an element.
Import
------
Import the Move primitives from `ng-primitives/interactions`.
import { NgpMove } from 'ng-primitives/interactions';
Usage
-----
Assemble the move directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpMove
The `NgpMove` directive is used to enable the pointer and keyboard move interactions on an element.
* Selector: `[ngpMove]`
* Exported As: `ngpMove`
Disables the move interaction. Emits when the move interaction starts. Emits when the move interaction is in progress. Emits when the move interaction ends.
#### Data Attributes
The following data attributes are available to use with the `NgpMove` directive:
| Attribute | Description |
| --- | --- |
| `data-move` | Applied when the element is being moved. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Focus Visible
=============
Determine whether focus should be visible based on user interaction. This is useful for accessibility and user experience, as it allows you to provide visual feedback when an element is focused using keyboard navigation, while not showing the focus outline when the user is using a mouse or touch device.
Import
------
Import the Focus Visible primitives from `ng-primitives/interactions`.
import { NgpFocusVisible } from 'ng-primitives/interactions';
Usage
-----
Assemble the focus-visible directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpFocusVisible
* Selector: `[ngpFocusVisible]`
* Exported As: `ngpFocusVisible`
Whether listening for focus-visible events is disabled. Event emitted when the focus visible state changes.
#### Data Attributes
The following data attributes are applied to the `ngpFocusVisible` directive:
| Attribute | Description |
| --- | --- |
| `data-focus-visible` | Applied when the element is focused via keyboard navigation. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Focus
=====
Normalizes the focus event across different browsers and devices.
Import
------
Import the Focus primitives from `ng-primitives/interactions`.
import { NgpFocus } from 'ng-primitives/interactions';
Usage
-----
Assemble the focus directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpFocus
* Selector: `[ngpFocus]`
* Exported As: `ngpFocus`
Whether listening for focus events is disabled. Event emitted when the focus state changes.
#### Data Attributes
The following data attributes are applied to the `ngpFocus` directive:
| Attribute | Description |
| --- | --- |
| `data-focus` | Applied when the element is focused. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Usage
=====
Angular Primitives are built entirely using Angular directives, offering a flexible and composable way to enhance your components.
There are two main ways to use them:
* Apply the directives directly in your component templates.
* Use the directives as **host directives** in your own components.
Let’s explore both approaches, along with some limitations and the solutions we provide.
* * *
Using Directives in Templates
-----------------------------
To use a directive in a template, simply apply it to the element you want to enhance. For example, here’s how you might use the `ngpSwitch` directive:
This applies the `ngpSwitch` directive to the button, enabling correct behavior and accessibility. You have full control over the inputs and outputs, making this approach ideal for many use cases.
However, this method has a few limitations. Some directives — like `ngpButton` — are intended to be used on specific elements (e.g. `button`). Wrapping such elements in your own component can make it difficult for consumers to add attributes like `type`, since you'd need to expose every possible attribute as an input manually.
To solve this, you can use **host directives**.
Using Directives as Host Directives
-----------------------------------
Host directives let you enhance your components by attaching existing directives at the class level. Here's how you can use `ngpButton` as a host directive:
import { Component } from '@angular/core';
import { NgpButton } from 'ng-primitives/button';
@Component({
selector: 'button[my-button]',
template: `
`,
hostDirectives: [NgpButton],
})
export class MyButtonComponent {
// You can add any additional inputs or outputs you want here
}
This approach allows consumers to apply attributes directly to the `button` element while still benefiting from the functionality provided by the directive.
You can also expose specific inputs and outputs from the directive to your component. For example:
import { Component, Input } from '@angular/core';
import { NgpButton } from 'ng-primitives/button';
@Component({
selector: 'button[my-button]',
template: `
`,
hostDirectives: [{ directive: NgpButton, inputs: ['disabled'] }],
})
export class MyButtonComponent {
}
This lets consumers bind to the `disabled` input just as if they were using `ngpButton` directly.
Limitations & Solutions
-----------------------
### Programmatically setting inputs
A key limitation of host directives in Angular is that their inputs can't be set programmatically within the component. To address this, we provide two main solutions:
#### Config Providers
Some directives support configuration providers that let you set default values. For example, to configure the default expansion type for `ngpAccordion`:
@Component({
selector: 'my-accordion',
template: `
`,
hostDirectives: [{ directive: NgpAccordion, inputs: ['type'] }],
providers: [provideAccordionConfig({ type: 'multiple' })],
})
export class MyAccordionComponent {}
Consumers can still override this default by explicitly binding to the `type` input.
#### State Providers
Other directives provide a **state provider**, allowing you to programmatically control their inputs. For example:
import { Component } from '@angular/core';
import { NgpSwitch, injectSwitchState } from 'ng-primitives/switch';
@Component({
selector: 'my-switch',
template: `
`,
hostDirectives: [NgpSwitch],
})
export class MySwitchComponent {
private readonly state = injectSwitchState();
constructor() {
this.state.checked.set(true);
}
}
Internally, all directive inputs are converted into **linked signals**, enabling both binding and programmatic updates.
### Splitting into Multiple Components
Some features are best implemented as multiple components. Take an accordion, for example:
Content for item 1
Content for item 2
If you're using `ngpAccordion` as a directive in the `my-accordion` template, the child `my-accordion-item` components won’t be able to locate it in the dependency injection tree. This is a known Angular limitation.
To solve this, Angular Primitives supports **state hoisting**, which allows you to share directive state between components.
#### State Hoisting Example
To hoist the state of `ngpAccordion` from the `my-accordion` component:
import { Component } from '@angular/core';
import { NgpAccordion, provideAccordionState } from 'ng-primitives/accordion';
@Component({
selector: 'my-accordion',
template: `
`,
providers: [provideAccordionState()],
})
export class MyAccordionComponent {}
Now, child directives like `ngpAccordionItem` can correctly locate and interact with the hoisted `ngpAccordion` state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Introduction
============
Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. Whether you're building a robust design system from scratch or looking to enhance your existing one, our primitives are here to support you every step of the way.
Key Features
------------
1. **Accessibility First:** We believe that all users should have equal access to information and functionality. Our primitives are crafted with accessibility best practices, ensuring that your applications are inclusive and usable by everyone.
2. **Customization Made Easy:** We understand the importance of maintaining a consistent look and feel across your applications. With Angular Primitives, we don't provide any styles, you provide your own to seamlessly blend with your brand's identity and visual guidelines.
3. **Developer Experience:** We know developers value simplicity and efficiency. Our library is designed to be intuitive and straightforward, making it a breeze for you to integrate and work with our primitives in your Angular projects. We follow the best practices and standards to ensure the highest quality code and documentation.
Versioning
----------
Angular Primitives follow [Semantic Versioning](https://semver.org/)
. As a result you can expect the following:
* **Patch releases** contain bug fixes and minor improvements.
* **Minor releases** contain new features and improvements.
* **Major releases** contain breaking changes.
We release a new major version each time Angular releases a new major version. This ensures that Angular Primitives is always up-to-date with the latest Angular features and best practices.
Compatibility
-------------
Angular Primitives versions are compatible with the following Angular versions:
| Angular Primitives | Angular |
| --- | --- |
| 0.1.0 - 0.18.0 | 18.0.x |
| 0.19.0+ | 19.0.x |
### Version Support Policy
Starting from v1.0.0, Angular Primitives will support the two latest major Angular versions. For example, when Angular 21 is released, Angular Primitives will support Angular 20 and 21. New major versions will be supported upon release (typically every six months), ensuring compatibility with the latest Angular features while allowing you to upgrade independently.
Community
---------
If you would like to stay up-to-date with the latest news and updates, or have any questions, feedback, or suggestions, we invite you to join our community on [Discord](https://discord.gg/NTdjc5r3gC)
.
Acknowledgements
----------------
Angular Primitives would not have been possible without inspiration from many of the great libraries that came before it. We would like to thank the following projects for their contributions to the open-source community:
* [Angular CDK](https://material.angular.io/cdk)
* [Radix UI](https://radix-ui.com/)
* [Headless UI](https://headlessui.com/)
* [React Aria](https://react-spectrum.adobe.com/react-aria/)
Support
-------
If you have any questions, feedback, or need help, feel free to reach out to us on [GitHub](https://github.com/ng-primitives/ng-primitives)
. We're always happy to help and improve our library based on your feedback.
If you're interested in contributing to Angular Primitives, please check out our [Contributing Guide](https://github.com/ng-primitives/ng-primitives/blob/main/CONTRIBUTING.md)
.
If you would like to support Angular Primitives to help us maintain and improve the library, please consider [sponsoring us](https://github.com/sponsors/ng-primitives)
. Your support is greatly appreciated!
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Styling
=======
Unlike traditional component libraries, Angular Primitives doesn't come with any built-in styles. This is because no matter how flexible a component library's theming system is, it can never meet the needs of every project or design system.
Angular Primitives gives you a set of basic building blocks that you can structure however you want, letting you style them exactly as you like.
Sure, this means you'll need to put in more effort than you would with an off the shelf component library. If you're just looking to quickly build something without worrying much about its appearance, Angular Primitives might not be the best fit. But if you want a way to quickly create custom components that look and behave exactly the way you want, Angular Primitives is a great choice.
Approach
--------
Angular Primitives has an opinionated way of handling styling. Each primitive uses `data-*` attributes to reflect its important state. This lets you style the primitives based on their state using CSS, so you don't have to manually toggle classes.
This works with any styling system, whether you're using plain CSS, SCSS, or a utility-first CSS framework like Tailwind CSS.
Example
-------
If you are using CSS or SCSS, you can style the primitives like this:
button[data-selected] {
background-color: blue;
color: white;
}
button[data-disabled] {
opacity: 0.5;
cursor: not-allowed;
}
If you are using Tailwind CSS, you can style the primitives like this:
Toggle
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Get Started
===========
Installation
------------
Angular Primitives is distributed as a single package with entrypoints for each primitive. This makes it easy to install and update, while keeping the bundle size as small as possible.
To install Angular Primitives using the Angular CLI, run the following command:
ng add ng-primitives
This command will install Angular Primitives and add the necessary dependencies to your project.
To install Angular Primitives using Nx, run the following command:
nx add ng-primitives
This command will install Angular Primitives and add the necessary dependencies to your project.
To manually install Angular Primitives, run the following command:
npm i ng-primitives
Peer Dependencies
-----------------
Angular Primitives relies on a few peer dependencies that need to be installed. If you are using NPM version 7 or higher, these dependencies will be installed automatically. If you are using an older version of NPM, or a different package manager, you may need to install them manually.
| Package | Version |
| --- | --- |
| @angular/cdk | \>=19.0.0 |
| @floating-ui/dom | \>=1.6.0 |
To install these dependencies, run the following command:
npm i @angular/cdk@^19.0.0 @floating-ui/dom@^1.6.0
Usage
-----
Once Angular Primitives is installed, you can start using the primitives in your Angular application. It is best to create a reusable component that encapsulates the primitives, so that you can easily reuse it throughout your application.
Primitives can be used both within a template or as a host directive on a component giving you the flexibility to choose the best approach for your use case.
Primitives add `data-` attributes to the elements they are applied to based on their current state. This allows you to easily style the primitives using CSS without having to rely on JavaScript.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Introduction
============
Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. Whether you're building a robust design system from scratch or looking to enhance your existing one, our primitives are here to support you every step of the way.
Key Features
------------
1. **Accessibility First:** We believe that all users should have equal access to information and functionality. Our primitives are crafted with accessibility best practices, ensuring that your applications are inclusive and usable by everyone.
2. **Customization Made Easy:** We understand the importance of maintaining a consistent look and feel across your applications. With Angular Primitives, we don't provide any styles, you provide your own to seamlessly blend with your brand's identity and visual guidelines.
3. **Developer Experience:** We know developers value simplicity and efficiency. Our library is designed to be intuitive and straightforward, making it a breeze for you to integrate and work with our primitives in your Angular projects. We follow the best practices and standards to ensure the highest quality code and documentation.
Versioning
----------
Angular Primitives follow [Semantic Versioning](https://semver.org/)
. As a result you can expect the following:
* **Patch releases** contain bug fixes and minor improvements.
* **Minor releases** contain new features and improvements.
* **Major releases** contain breaking changes.
We release a new major version each time Angular releases a new major version. This ensures that Angular Primitives is always up-to-date with the latest Angular features and best practices.
Compatibility
-------------
Angular Primitives versions are compatible with the following Angular versions:
| Angular Primitives | Angular |
| --- | --- |
| 0.1.0 - 0.18.0 | 18.0.x |
| 0.19.0+ | 19.0.x |
### Version Support Policy
Starting from v1.0.0, Angular Primitives will support the two latest major Angular versions. For example, when Angular 21 is released, Angular Primitives will support Angular 20 and 21. New major versions will be supported upon release (typically every six months), ensuring compatibility with the latest Angular features while allowing you to upgrade independently.
Community
---------
If you would like to stay up-to-date with the latest news and updates, or have any questions, feedback, or suggestions, we invite you to join our community on [Discord](https://discord.gg/NTdjc5r3gC)
.
Acknowledgements
----------------
Angular Primitives would not have been possible without inspiration from many of the great libraries that came before it. We would like to thank the following projects for their contributions to the open-source community:
* [Angular CDK](https://material.angular.io/cdk)
* [Radix UI](https://radix-ui.com/)
* [Headless UI](https://headlessui.com/)
* [React Aria](https://react-spectrum.adobe.com/react-aria/)
Support
-------
If you have any questions, feedback, or need help, feel free to reach out to us on [GitHub](https://github.com/ng-primitives/ng-primitives)
. We're always happy to help and improve our library based on your feedback.
If you're interested in contributing to Angular Primitives, please check out our [Contributing Guide](https://github.com/ng-primitives/ng-primitives/blob/main/CONTRIBUTING.md)
.
If you would like to support Angular Primitives to help us maintain and improve the library, please consider [sponsoring us](https://github.com/sponsors/ng-primitives)
. Your support is greatly appreciated!
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Introduction
============
Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. Whether you're building a robust design system from scratch or looking to enhance your existing one, our primitives are here to support you every step of the way.
Key Features
------------
1. **Accessibility First:** We believe that all users should have equal access to information and functionality. Our primitives are crafted with accessibility best practices, ensuring that your applications are inclusive and usable by everyone.
2. **Customization Made Easy:** We understand the importance of maintaining a consistent look and feel across your applications. With Angular Primitives, we don't provide any styles, you provide your own to seamlessly blend with your brand's identity and visual guidelines.
3. **Developer Experience:** We know developers value simplicity and efficiency. Our library is designed to be intuitive and straightforward, making it a breeze for you to integrate and work with our primitives in your Angular projects. We follow the best practices and standards to ensure the highest quality code and documentation.
Versioning
----------
Angular Primitives follow [Semantic Versioning](https://semver.org/)
. As a result you can expect the following:
* **Patch releases** contain bug fixes and minor improvements.
* **Minor releases** contain new features and improvements.
* **Major releases** contain breaking changes.
We release a new major version each time Angular releases a new major version. This ensures that Angular Primitives is always up-to-date with the latest Angular features and best practices.
Compatibility
-------------
Angular Primitives versions are compatible with the following Angular versions:
| Angular Primitives | Angular |
| --- | --- |
| 0.1.0 - 0.18.0 | 18.0.x |
| 0.19.0+ | 19.0.x |
### Version Support Policy
Starting from v1.0.0, Angular Primitives will support the two latest major Angular versions. For example, when Angular 21 is released, Angular Primitives will support Angular 20 and 21. New major versions will be supported upon release (typically every six months), ensuring compatibility with the latest Angular features while allowing you to upgrade independently.
Community
---------
If you would like to stay up-to-date with the latest news and updates, or have any questions, feedback, or suggestions, we invite you to join our community on [Discord](https://discord.gg/NTdjc5r3gC)
.
Acknowledgements
----------------
Angular Primitives would not have been possible without inspiration from many of the great libraries that came before it. We would like to thank the following projects for their contributions to the open-source community:
* [Angular CDK](https://material.angular.io/cdk)
* [Radix UI](https://radix-ui.com/)
* [Headless UI](https://headlessui.com/)
* [React Aria](https://react-spectrum.adobe.com/react-aria/)
Support
-------
If you have any questions, feedback, or need help, feel free to reach out to us on [GitHub](https://github.com/ng-primitives/ng-primitives)
. We're always happy to help and improve our library based on your feedback.
If you're interested in contributing to Angular Primitives, please check out our [Contributing Guide](https://github.com/ng-primitives/ng-primitives/blob/main/CONTRIBUTING.md)
.
If you would like to support Angular Primitives to help us maintain and improve the library, please consider [sponsoring us](https://github.com/sponsors/ng-primitives)
. Your support is greatly appreciated!
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Styling
=======
Unlike traditional component libraries, Angular Primitives doesn't come with any built-in styles. This is because no matter how flexible a component library's theming system is, it can never meet the needs of every project or design system.
Angular Primitives gives you a set of basic building blocks that you can structure however you want, letting you style them exactly as you like.
Sure, this means you'll need to put in more effort than you would with an off the shelf component library. If you're just looking to quickly build something without worrying much about its appearance, Angular Primitives might not be the best fit. But if you want a way to quickly create custom components that look and behave exactly the way you want, Angular Primitives is a great choice.
Approach
--------
Angular Primitives has an opinionated way of handling styling. Each primitive uses `data-*` attributes to reflect its important state. This lets you style the primitives based on their state using CSS, so you don't have to manually toggle classes.
This works with any styling system, whether you're using plain CSS, SCSS, or a utility-first CSS framework like Tailwind CSS.
Example
-------
If you are using CSS or SCSS, you can style the primitives like this:
button[data-selected] {
background-color: blue;
color: white;
}
button[data-disabled] {
opacity: 0.5;
cursor: not-allowed;
}
If you are using Tailwind CSS, you can style the primitives like this:
Toggle
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Usage
=====
Angular Primitives are built entirely using Angular directives, offering a flexible and composable way to enhance your components.
There are two main ways to use them:
* Apply the directives directly in your component templates.
* Use the directives as **host directives** in your own components.
Let’s explore both approaches, along with some limitations and the solutions we provide.
* * *
Using Directives in Templates
-----------------------------
To use a directive in a template, simply apply it to the element you want to enhance. For example, here’s how you might use the `ngpSwitch` directive:
This applies the `ngpSwitch` directive to the button, enabling correct behavior and accessibility. You have full control over the inputs and outputs, making this approach ideal for many use cases.
However, this method has a few limitations. Some directives — like `ngpButton` — are intended to be used on specific elements (e.g. `button`). Wrapping such elements in your own component can make it difficult for consumers to add attributes like `type`, since you'd need to expose every possible attribute as an input manually.
To solve this, you can use **host directives**.
Using Directives as Host Directives
-----------------------------------
Host directives let you enhance your components by attaching existing directives at the class level. Here's how you can use `ngpButton` as a host directive:
import { Component } from '@angular/core';
import { NgpButton } from 'ng-primitives/button';
@Component({
selector: 'button[my-button]',
template: `
`,
hostDirectives: [NgpButton],
})
export class MyButtonComponent {
// You can add any additional inputs or outputs you want here
}
This approach allows consumers to apply attributes directly to the `button` element while still benefiting from the functionality provided by the directive.
You can also expose specific inputs and outputs from the directive to your component. For example:
import { Component, Input } from '@angular/core';
import { NgpButton } from 'ng-primitives/button';
@Component({
selector: 'button[my-button]',
template: `
`,
hostDirectives: [{ directive: NgpButton, inputs: ['disabled'] }],
})
export class MyButtonComponent {
}
This lets consumers bind to the `disabled` input just as if they were using `ngpButton` directly.
Limitations & Solutions
-----------------------
### Programmatically setting inputs
A key limitation of host directives in Angular is that their inputs can't be set programmatically within the component. To address this, we provide two main solutions:
#### Config Providers
Some directives support configuration providers that let you set default values. For example, to configure the default expansion type for `ngpAccordion`:
@Component({
selector: 'my-accordion',
template: `
`,
hostDirectives: [{ directive: NgpAccordion, inputs: ['type'] }],
providers: [provideAccordionConfig({ type: 'multiple' })],
})
export class MyAccordionComponent {}
Consumers can still override this default by explicitly binding to the `type` input.
#### State Providers
Other directives provide a **state provider**, allowing you to programmatically control their inputs. For example:
import { Component } from '@angular/core';
import { NgpSwitch, injectSwitchState } from 'ng-primitives/switch';
@Component({
selector: 'my-switch',
template: `
`,
hostDirectives: [NgpSwitch],
})
export class MySwitchComponent {
private readonly state = injectSwitchState();
constructor() {
this.state.checked.set(true);
}
}
Internally, all directive inputs are converted into **linked signals**, enabling both binding and programmatic updates.
### Splitting into Multiple Components
Some features are best implemented as multiple components. Take an accordion, for example:
Content for item 1
Content for item 2
If you're using `ngpAccordion` as a directive in the `my-accordion` template, the child `my-accordion-item` components won’t be able to locate it in the dependency injection tree. This is a known Angular limitation.
To solve this, Angular Primitives supports **state hoisting**, which allows you to share directive state between components.
#### State Hoisting Example
To hoist the state of `ngpAccordion` from the `my-accordion` component:
import { Component } from '@angular/core';
import { NgpAccordion, provideAccordionState } from 'ng-primitives/accordion';
@Component({
selector: 'my-accordion',
template: `
`,
providers: [provideAccordionState()],
})
export class MyAccordionComponent {}
Now, child directives like `ngpAccordionItem` can correctly locate and interact with the hoisted `ngpAccordion` state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Accordion
=========
Display a series of panels that can be expanded or collapsed.
Import
------
Import the Accordion primitives from `ng-primitives/accordion`.
import {
NgpAccordion,
NgpAccordionItem,
NgpAccordionTrigger,
NgpAccordionContent,
} from 'ng-primitives/accordion';
Usage
-----
Assemble the accordion directives in your template.
Would you like to learn more?
If you would like to learn more please reach out to us on GitHub.
Can I use this in my project?
Yes, this is open source and you can use it in your project.
Reusable Component
------------------
Create reusable components that uses the `NgpAccordion` and `NgpAccordionItem` directives.
Schematics
----------
Generate a reusable accordion component using the Angular CLI.
ng g ng-primitives:primitive accordion
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/accordion` package:
### NgpAccordion
Apply the `ngpAccordion` directive to an element that represents the group of accordion items.
* Selector: `[ngpAccordion]`
* Exported As: `ngpAccordion`
Define whether only one or multiple accordion items can be open at a time. Define an accordion can be collapsed. This is only applicable when \`ngpAccordionType\` is set to \`single\`. Define the expanded accordion items. This should be a single value when \`ngpAccordionType\` is set to \`single\` and an array when set to \`multiple\`. Define whether the accordion is disabled. Define the orientation of the accordion. Emitted when the expanded accordion items change. This will be a single value when \`ngpAccordionType\` is set to \`single\` and an array when set to \`multiple\`.
#### Data Attributes
The following data attributes are applied to the `ngpAccordion` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-disabled` | Applied when the element is disabled. | `-` |
### NgpAccordionItem
Apply the `ngpAccordionItem` directive to an element that represents an accordion item.
* Selector: `[ngpAccordionItem]`
* Exported As: `ngpAccordionItem`
Define the value of the accordion item. Define whether the accordion item is disabled.
#### Data Attributes
The following data attributes are applied to the `ngpAccordionItem` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-open` | Applied when the accordion item is open. | `-` |
| `data-disabled` | Applied when the accordion item is disabled. | `-` |
### NgpAccordionTrigger
Apply the `ngpAccordionTrigger` directive to an element that represents the trigger for an accordion item, such as a button.
* Selector: `[ngpAccordionTrigger]`
* Exported As: `ngpAccordionTrigger`
#### Data Attributes
The following data attributes are applied to the `ngpAccordionTrigger` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-open` | Applied when the accordion item is open. | `-` |
| `data-disabled` | Applied when the accordion item is disabled. | `-` |
### NgpAccordionContent
Apply the `ngpAccordionContent` directive to an element that represents the content of an accordion item.
* Selector: `[ngpAccordionContent]`
* Exported As: `ngpAccordionContent`
#### Data Attributes
The following data attributes are applied to the `ngpAccordionContent` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the accordion. | `horizontal` \| `vertical` |
| `data-open` | Applied when the accordion item is open. | `-` |
Global Configuration
--------------------
You can configure the default options for all accordions in your application by using the `provideAccordionConfig` function in a providers array.
import { provideAccordionConfig } from 'ng-primitives/accordion';
bootstrapApplication(AppComponent, {
providers: [\
provideAccordionConfig({\
type: 'multiple',\
collapsible: true,\
orientation: 'horizontal',\
}),\
],
});
### NgpAccordionConfig
Define whether only one or multiple accordion items can be open at a time. Define an accordion can be collapsed. This is only applicable when \`type\` is set to \`single\`. Define the orientation of the accordion.
Accessibility
-------------
Adheres to the [Accordion WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion)
.
### Keyboard Interactions
* Space - Toggle the expanded state of the accordion item when the trigger is focused.
* Enter - Toggle the expanded state of the accordion item when the trigger is focused.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Dialog
======
A dialog is a floating window that can be used to display information or prompt the user for input.
Import
------
Import the Dialog primitives from `ng-primitives/dialog`.
import {
NgpDialog,
NgpDialogTitle,
NgpDialogDescription,
NgpDialogTrigger,
NgpDialogOverlay,
} from 'ng-primitives/dialog';
Usage
-----
Assemble the dialog directives in your template.
Launch Dialog
Publish this article?
Are you sure you want to publish this article? This action is irreversible.
API Reference
-------------
The following directives are available to import from the `ng-primitives/dialog` package:
### NgpDialog
The dialog container.
* Selector: `[ngpDialog]`
* Exported As: `ngpDialog`
The role of the dialog. Use \`'dialog'\` for dialogs that require user interaction and \`'alertdialog'\` for dialogs that require immediate user attention. Whether the dialog is modal. A modal dialog prevents the user from interacting with the rest of the page until the dialog is closed.
| Attribute | Description |
| --- | --- |
| `data-closing` | Applied when the dialog is closing. |
### NgpDialogTitle
The dialog title.
* Selector: `[ngpDialogTitle]`
* Exported As: `ngpDialogTitle`
### NgpDialogDescription
The dialog description.
* Selector: `[ngpDialogDescription]`
* Exported As: `ngpDialogDescription`
### NgpDialogTrigger
Add to a button or link to open the dialog.
* Selector: `[ngpDialogTrigger]`
* Exported As: `ngpDialogTrigger`
The dialog template to open when the trigger is activated.
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the trigger is hovered. |
| `data-focus-visible` | Applied when the trigger is focused. |
| `data-press` | Applied when the trigger is pressed. |
| `data-disabled` | Applied when the trigger is disabled. |
### NgpDialogOverlay
The dialog overlay.
* Selector: `[ngpDialogOverlay]`
* Exported As: `ngpDialogOverlay`
| Attribute | Description |
| --- | --- |
| `data-closing` | Applied when the dialog is closing. |
Examples
--------
### Dialog with external data
Data can be passed to the dialog using the `NgpDialogManager`.
### Drawer
A drawer is a type of dialog that slides in from the side of the screen.
Accessibility
-------------
Adheres to the [WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/dialog/)
.
### Keyboard Interactions
* Esc: Close the dialog.
* Tab: Navigate through focusable elements within the dialog.
* Shift + Tab: Navigate backwards through focusable elements within the dialog.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Getting Started
Get Started
===========
Installation
------------
Angular Primitives is distributed as a single package with entrypoints for each primitive. This makes it easy to install and update, while keeping the bundle size as small as possible.
To install Angular Primitives using the Angular CLI, run the following command:
ng add ng-primitives
This command will install Angular Primitives and add the necessary dependencies to your project.
To install Angular Primitives using Nx, run the following command:
nx add ng-primitives
This command will install Angular Primitives and add the necessary dependencies to your project.
To manually install Angular Primitives, run the following command:
npm i ng-primitives
Peer Dependencies
-----------------
Angular Primitives relies on a few peer dependencies that need to be installed. If you are using NPM version 7 or higher, these dependencies will be installed automatically. If you are using an older version of NPM, or a different package manager, you may need to install them manually.
| Package | Version |
| --- | --- |
| @angular/cdk | \>=19.0.0 |
| @floating-ui/dom | \>=1.6.0 |
To install these dependencies, run the following command:
npm i @angular/cdk@^19.0.0 @floating-ui/dom@^1.6.0
Usage
-----
Once Angular Primitives is installed, you can start using the primitives in your Angular application. It is best to create a reusable component that encapsulates the primitives, so that you can easily reuse it throughout your application.
Primitives can be used both within a template or as a host directive on a component giving you the flexibility to choose the best approach for your use case.
Primitives add `data-` attributes to the elements they are applied to based on their current state. This allows you to easily style the primitives using CSS without having to rely on JavaScript.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Avatar
======
Display an image that represents a user with a text fallback.
Import
------
Import the Avatar primitives from `ng-primitives/avatar`.
import { NgpAvatar, NgpAvatarImage, NgpAvatarFallback } from 'ng-primitives/avatar';
Usage
-----
Assemble the avatar directives in your template.
NG
Reusable Component
------------------
Create a reusable component that uses the `NgpAvatar` directive.
Schematics
----------
Generate a reusable avatar component using the Angular CLI.
ng g ng-primitives:primitive avatar
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/avatar` package:
### NgpAvatar
Apply the `ngpAvatar` directive to an element that represents the avatar. This directive is a container for the image and/or fallback.
* Selector: `[ngpAvatar]`
* Exported As: `ngpAvatar`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-status` | The loading status of the avatar image. | `idle` \| `loading` \| `loaded` \| `error` |
| `data-hover` | The added to the avatar when hovered. | `-` |
| `data-focus-visible` | The added to the avatar when focus visible. | `-` |
| `data-press` | The added to the avatar when pressed. | `-` |
### NgpAvatarImage
Apply the `ngpAvatarImage` directive to an element that represents the avatar image. This would typically be an `img` element or a `div` with a background image.
* Selector: `[ngpAvatarImage]`
* Exported As: `ngpAvatarImage`
* Host Directives: [NgpVisuallyHidden](/utilities/visually-hidden)
### NgpAvatarFallback
Apply the `ngpAvatarFallback` directive to an element that represents the user in the absence of an image. This is typically the user's initials.
* Selector: `[ngpAvatarFallback]`
* Exported As: `ngpAvatarFallback`
Define a delay before the fallback is shown. This is useful to only show the fallback for those with slower connections.
Global Configuration
--------------------
You can configure the default options for all avatars in your application by using the `provideAvatarConfig` function in a providers array.
import { provideAvatarConfig } from 'ng-primitives/avatar';
bootstrapApplication(AppComponent, {
providers: [provideAvatarConfig({ delay: 1000 })],
});
### NgpAvatarConfig
Define a delay before the fallback is shown. This is useful to only show the fallback for those with slower connections.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Checkbox
========
Perform state toggling.
Import
------
Import the Checkbox primitives from `ng-primitives/checkbox`.
import { NgpCheckbox } from 'ng-primitives/checkbox';
Usage
-----
Assemble the checkbox directives in your template.
Reusable Component
------------------
Create a reusable component that uses the `NgpCheckbox` directive.
Schematics
----------
Generate a reusable checkbox component using the Angular CLI.
ng g ng-primitives:primitive checkbox
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Checkbox primitives.
### Checkbox Form Field
The checkbox automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/checkbox` package:
### NgpCheckbox
Apply the `ngpCheckbox` directive to an element to that represents the checkbox, such as a `button`.
* Selector: `[ngpCheckbox]`
* Exported As: `ngpCheckbox`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the checked state. Define the interminate state. Define the disabled state. Event emitted when the state changes. Event emitted when the indeterminate state changes.
| 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. |
Accessibility
-------------
Adheres to the [Tri-State Checkbox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox)
.
### Keyboard Interactions
* Space - Toggle the checked state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
File Upload
===========
The file upload primitive allows you to trigger a file upload from any element, giving you the more control over the appearance and behavior compared to the native file input.
Import
------
Import the FileUpload primitives from `ng-primitives/file-upload`.
import { NgpFileUpload } from 'ng-primitives/file-upload';
Usage
-----
Assemble the file-upload directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/file-upload` package:
### NgpFileUpload
A directive that allows you to turn any element into a file upload trigger.
* Selector: `[ngpFileUpload]`
* Exported As: `ngpFileUpload`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define if multiple files can be selected. Define the file types that can be selected. Define if directories can be selected. Define if drag and drop is enabled. Define if the file upload is disabled. Event emitted when files are selected. Event emitted when the user cancels the file upload or selects the same file(s) again. Event emitted when a file is dragged over or out of the element.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the element is hovered. |
| `data-focus-visible` | Applied when the element is focus visible. |
| `data-press` | Applied when the element is pressed. |
| `data-dragover` | Applied when a file is dragged over the element. |
| `data-disabled` | Applied when the element is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Button
======
A button is a clickable element that can be used to trigger an action. This primitive enhances the native button element with improved accessibility and interaction handling for hover, press and focus.
Import
------
Import the Button primitives from `ng-primitives/button`.
import { NgpButton } from 'ng-primitives/button';
Usage
-----
Assemble the button directives in your template.
Button
Reusable Component
------------------
Create a button component that uses the `NgpButton` directive.
Schematics
----------
Generate a reusable button component using the Angular CLI.
ng g ng-primitives:primitive button
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/button` package:
### NgpButton
A directive that can be used to create a button.
* Selector: `[ngpButton]`
* Exported As: `ngpButton`
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Added to the button when hovered. |
| `data-focus-visible` | Added to the button when focused. |
| `data-press` | Added to the button when pressed. |
| `data-disabled` | Added to the button when disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Date Picker
===========
A date picker is a component that allows users to select a date from a calendar and navigate through months and years.
Import
------
Import the DatePicker primitives from `ng-primitives/date-picker`.
import {
NgpDatePicker,
NgpDatePickerLabel,
NgpDatePickerNextMonth,
NgpDatePickerPreviousMonth,
NgpDatePickerGrid,
NgpDatePickerCell,
NgpDatePickerRowRender,
NgpDatePickerCellRender,
NgpDatePickerDateButton,
} from 'ng-primitives/date-picker';
Usage
-----
Assemble the date-picker directives in your template.
Reusable Component
------------------
Create a reusable component that uses the date picker directives.
Schematics
----------
Generate a reusable date-picker component using the Angular CLI.
ng g ng-primitives:primitive date-picker
### Options
* `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`.
API Reference
-------------
By default, the date picker uses the native JavaScript `Date` object, however the date picker is designed to work with any date library. To use a date library, such as Luxon, you need to specify the appropriate date adapter. The date adapter is an abstraction layer that allows components to use date objects from any date library, ensuring compatibility and easy integration. To learn more about the date adapter, see the [Date Adapter](/utilities/date-adapter)
documentation.
The following directives are available to import from the `ng-primitives/date-picker` package:
### NgpDatePicker
The outermost container for the date picker.
* Selector: `[ngpDatePicker]`
* Exported As: `ngpDatePicker`
Define the selected date. The type \`T\` is a generic type that represents the date value which can be a \`Date\` or a custom Date object handled by a \`NgpDateAdapter\`. Define the minimum date that can be selected. Define the maximum date that can be selected. Define the disabled state. Define a function that determines if a date is disabled. The function receives a date value and should return \`true\` if the date is disabled. Define the focused date.
#### Data Attributes
The following data attributes are available on the `ngpDatePicker` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the date picker is disabled. |
### NgpDatePickerLabel
The label that displays the current month and year typically in the header of the date picker. This will be announced by screen readers when the date changes.
* Selector: `[ngpDatePickerLabel]`
* Exported As: `ngpDatePickerLabel`
#### Data Attributes
The following data attributes are available on the `ngpDatePickerLabel` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the date picker is disabled. |
### NgpDatePickerPreviousMonth
A button that navigates to the previous month.
* Selector: `[ngpDatePickerPreviousMonth]`
* Exported As: `ngpDatePickerPreviousMonth`
* Host Directives: [NgpButton](/primitives/button)
#### Data Attributes
The following data attributes are available on the `ngpDatePickerPreviousMonth` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpDatePickerNextMonth
A button that navigates to the next month.
* Selector: `[ngpDatePickerNextMonth]`
* Exported As: `ngpDatePickerNextMonth`
* Host Directives: [NgpButton](/primitives/button)
#### Data Attributes
The following data attributes are available on the `ngpDatePickerNextMonth` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpDatePickerGrid
The grid that contains the days of the month.
* Selector: `[ngpDatePickerGrid]`
* Exported As: `ngpDatePickerGrid`
#### Data Attributes
The following data attributes are available on the `ngpDatePickerGrid` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the date picker is disabled. |
### NgpDatePickerRowRender
A structural directive that renders a row of weekdays in the date picker grid.
* Selector: `*ngpDatePickerRowRender`
* Exported As: `ngpDatePickerRowRender`
### NgpDatePickerCellRender
A structural directive that renders a cell in the date picker grid.
* Selector: `*ngpDatePickerCellRender`
* Exported As: `ngpDatePickerCellRender`
The following context fields are available on the `ngpDatePickerCellRender` directive:
The date value for the cell.
### NgpDatePickerCell
A cell in the date picker grid.
* Selector: `[ngpDatePickerCell]`
* Exported As: `ngpDatePickerCell`
#### Data Attributes
The following data attributes are available on the `ngpDatePickerCell` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the cell is disabled. |
| `data-selected` | Applied when the cell is selected. |
### NgpDatePickerDateButton
A button that represents a date in the date picker grid.
* Selector: `[ngpDatePickerDateButton]`
* Exported As: `ngpDatePickerDateButton`
* Host Directives: [NgpButton](/primitives/button)
#### Data Attributes
The following data attributes are available on the `ngpDatePickerDateButton` directive:
| Attribute | Description |
| --- | --- |
| `data-selected` | Applied when the button is selected. |
| `data-outside-month` | Applied when the button is outside the current month. |
| `data-today` | Applied when the button represents the current date. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
Accessibility
-------------
Adheres to the [WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/)
.
### Keyboard Interactions
* Space - Selects the focused date.
* Enter - Selects the focused date.
* ArrowUp - Moves focus to the same day of the previous week.
* ArrowDown - Moves focus to the same day of the next week.
* ArrowLeft - Moves focus to the previous day.
* ArrowRight - Moves focus to the next day.
* Home - Moves focus to the first day of the month.
* End - Moves focus to the last day of the month.
* PageUp - Moves focus to the same date in the previous month.
* PageDown - Moves focus to the same date in the next month.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Icons
=====
Enhance your application by providing a visually appealing and intuitive way to represent actions, statuses, and features. Icons improve user experience, aid in navigation, and help convey information quickly.
We also maintain the popular [Angular Icons library](https://ng-icons.github.io/ng-icons)
which gives you access to over 50,000 icons from popular icon libraries like Font Awesome, Material Design, Heroicons and more.
Import
------
The `NgIcon` component is used to render icons in your application. To use icons, you need to import the `NgIcon` directive from `@ng-icons/core`.
Icons must be registered using the `provideIcons` function. The icons you want to use must be individually imported from their respective packages.
import { NgIcon, provideIcons } from '@ng-icons/core';
import { featherAirplay } from '@ng-icons/feather-icons';
import { heroUsers } from '@ng-icons/heroicons/outline';
@Component({
selector: 'app-root',
template: `
`,
imports: [NgIcon],
viewProviders: [provideIcons({ featherAirplay, heroUsers })],
})
export class AppComponent {}
View the full list of available icons in the [Angular Icons documentation](https://ng-icons.github.io/ng-icons/#/browse-icons)
.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Listbox
=======
A listbox presents a set of choices and lets users select one or multiple options. It can be paired with the `NgpPopover` directive to create a dropdown listbox.
Import
------
Import the Listbox primitives from `ng-primitives/listbox`.
import { NgpListbox } from 'ng-primitives/listbox';
Usage
-----
Assemble the listbox directives in your template.
Option 1
Option 2
Option 3
Reusable Component
------------------
Create a reusable component that uses the listbox directives.
Schematics
----------
Generate a reusable listbox component using the Angular CLI.
ng g ng-primitives:primitive listbox
### Options
* `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`.
Examples
--------
### Single-Select Listbox
The listbox can be configured to allow a single selection.
### Multi-Select Listbox
The listbox can be configured to allow multiple selections.
### Listbox with Sections
The listbox can be configured to have sections and headers.
API Reference
-------------
The following directives are available to import from the `ng-primitives/listbox` package:
### NgpListbox
* Selector: `[ngpListbox]`
* Exported As: `ngpListbox`
The selection mode of the listbox. Can be either \`single\` or \`multiple\`. The selected value(s) of the listbox. Whether the listbox is disabled. A function to compare two values of the listbox. The function should return \`true\` if the values are equal. This is useful when the listbox options are objects.
#### Data Attributes
The following data attributes are applied to the `ngpListbox` directive:
| Attribute | Description |
| --- | --- |
| `data-focus-visible` | Applied to the listbox when focused via the keyboard. |
### NgpListboxOption
* Selector: `[ngpListboxOption]`
* Exported As: `ngpListboxOption`
The value of the option. Whether the option is disabled.
#### Data Attributes
The following data attributes are applied to the `ngpListboxOption` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied to the listbox option when hovered. |
| `data-focus` | Applied to the listbox option when focused. |
| `data-focus-visible` | Applied to the listbox option when focused via the keyboard. |
| `data-disabled` | Applied to the listbox option when disabled. |
| `data-active` | Applied to the listbox option when it is the active descendant. |
| `data-disabled` | Applied to the listbox option when it is disabled. |
| `data-selected` | Applied to the listbox option when it is selected. |
### NgpListboxSection
* Selector: `[ngpListboxSection]`
* Exported As: `ngpListboxSection`
### NgpListboxTrigger
* Selector: `[ngpListboxTrigger]`
* Exported As: `ngpListboxTrigger`
Augments the popover trigger with listbox-specific behavior, such as opening the listbox when the arrow keys are pressed.
Accessibility
-------------
Adheres to the [WAI-ARIA Listbox Design Pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#Listbox)
.
### Keyboard Interactions
* Arrow Down - Move focus to the next option.
* Arrow Up - Move focus to the previous option.
* Home - Move focus to the first option.
* End - Move focus to the last option.
* Space - Select the focused option.
* Enter - Select the focused option.
* Escape - Close the listbox.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Form Field
==========
Import
------
Import the FormField primitives from `ng-primitives/form-field`.
import {
NgpFormField,
NgpLabel,
NgpDescription,
NgpError,
NgpFormControl,
} from 'ng-primitives/form-field';
Usage
-----
Assemble the form-field directives in your template.
Reusable Component
------------------
Create a reusable component that uses the `NgpFormField` directive.
Schematics
----------
Generate a reusable form-field component using the Angular CLI.
ng g ng-primitives:primitive form-field
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/form-field` package:
### NgpFormField
The `NgpFormField` directive is a container for form field elements. Any labels, form controls, or descriptions should be placed within this directive.
* Selector: `[ngpFormField]`
* Exported As: `ngpFormField`
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-invalid` | Applied when the form control is invalid. |
| `data-valid` | Applied when the form control is valid. |
| `data-touched` | Applied when the form control is touched. |
| `data-pristine` | Applied when the form control is pristine. |
| `data-dirty` | Applied when the form control is dirty. |
| `data-pending` | Applied when the form control is pending. |
| `data-disabled` | Applied when the form control is disabled. |
### NgpLabel
The `NgpLabel` directive is used to mark a label element within a form field. Preferably, there should use an HTML `` element.
* Selector: `[ngpLabel]`
* Exported As: `ngpLabel`
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-invalid` | Applied when the form control is invalid. | |
| `data-valid` | Applied when the form control is valid. | |
| `data-touched` | Applied when the form control is touched. | |
| `data-pristine` | Applied when the form control is pristine. | |
| `data-dirty` | Applied when the form control is dirty. | |
| `data-pending` | Applied when the form control is pending. | |
| `data-disabled` | Applied when the form control is disabled. | |
### NgpDescription
The `NgpDescription` directive is used to mark a description element within a form field. There may be multiple descriptions associated with a form control.
* Selector: `[ngpDescription]`
* Exported As: `ngpDescription`
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-invalid` | Applied when the form control is invalid. | |
| `data-valid` | Applied when the form control is valid. | |
| `data-touched` | Applied when the form control is touched. | |
| `data-pristine` | Applied when the form control is pristine. | |
| `data-dirty` | Applied when the form control is dirty. | |
| `data-pending` | Applied when the form control is pending. | |
| `data-disabled` | Applied when the form control is disabled. | |
### NgpError
The `NgpError` directive is used to mark an error message element within a form field. There may be multiple error messages associated with a form control.
* Selector: `[ngpError]`
* Exported As: `ngpError`
The name of the validator associated with this error message.
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-validator` | Whether the validator specified in `ngpErrorValidator` is failing. | `fail` \| `pass` |
| `data-invalid` | Applied when the form control is invalid. | `-` |
| `data-valid` | Applied when the form control is valid. | `-` |
| `data-touched` | Applied when the form control is touched. | `-` |
| `data-pristine` | Applied when the form control is pristine. | `-` |
| `data-dirty` | Applied when the form control is dirty. | `-` |
| `data-pending` | Applied when the form control is pending. | `-` |
| `data-disabled` | Applied when the form control is disabled. | `-` |
### NgpFormControl
Typically this primitive would be not be used directly, but instead a more specific form control primitive would be used (e.g. `ngpInput`). All of our form control primitives use `ngpFormControl` internally so they will have the same accessibility features as described below.
The `NgpFormControl` directive is used to mark a form control element within a form field. This element will have an `aria-labelledby` attribute set to the ID of the label element within the form field and an `aria-describedby` attribute set to the ID of the description elements within the form field.
* Selector: `[ngpFormControl]`
* Exported As: `ngpFormControl`
#### Data Attributes
| Attribute | Description | Value |
| --- | --- | --- |
| `data-invalid` | Applied when the form control is invalid. | |
| `data-valid` | Applied when the form control is valid. | |
| `data-touched` | Applied when the form control is touched. | |
| `data-pristine` | Applied when the form control is pristine. | |
| `data-dirty` | Applied when the form control is dirty. | |
| `data-pending` | Applied when the form control is pending. | |
| `data-disabled` | Applied when the form control is disabled. | |
Accessibility
-------------
The label and description elements should be associated with the form control using the `aria-labelledby` and `aria-describedby` attributes, respectively. This will ensure that screen readers can provide the necessary context to users.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Menu
====
A menu is a list of options or commands presented to the user in a dropdown list.
Import
------
Import the Menu primitives from `ng-primitives/menu`.
import { NgpMenu, NgpMenuItem, NgpMenuTrigger, NgpSubmenuTrigger } from 'ng-primitives/menu';
Usage
-----
Assemble the menu directives in your template.
Examples
--------
Here are some additional examples of how to use the Menu primitives.
### Submenu
The menu can contain submenus, which are nested menus that can be opened by hovering on a menu item.
API Reference
-------------
The following directives are available to import from the `ng-primitives/menu` package:
### NgpMenuTrigger
The `NgpMenuTrigger` directive allows you to turn an element into a menu trigger.
* Selector: `[ngpMenuTrigger]`
* Exported As: `ngpMenuTrigger`
The menu template to display when the trigger is activated.
#### Data Attributes
The following data attributes are available on the `NgpMenuTrigger` directive:
| Attribute | Description |
| --- | --- |
| `data-open` | Applied when the menu is open. |
### NgpMenu
The `NgpMenu` is a container for menu items.
* Selector: `[ngpMenu]`
* Exported As: `ngpMenu`
### NgpMenuItem
The `NgpMenuItem` directive represents a menu item.
* Selector: `[ngpMenuItem]`
* Exported As: `ngpMenuItem`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define if the menu item is disabled.
#### Data Attributes
The following data attributes are available on the `NgpMenuItem` directive:
| Attribute | Description |
| --- | --- |
| `data-disabled` | Applied when the item is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Popover
=======
Display arbitrary content inside floating panels.
Import
------
Import the Popover primitives from `ng-primitives/popover`.
import { NgpPopover } from 'ng-primitives/popover';
Usage
-----
Assemble the popover directives in your template.
Click me
Popover content
API Reference
-------------
The following directives are available to import from the `ng-primitives/popover` package:
### NgpPopover
Apply the `ngpPopover` directive to an element that represents the popover. This typically would be a `div` inside an `ng-template`.
* Selector: `[ngpPopover]`
* Exported As: `ngpPopover`
### NgpPopoverTrigger
Apply the `ngpPopoverTrigger` directive to an element that triggers the popover to show.
* Selector: `[ngpPopoverTrigger]`
* Exported As: `ngpPopoverTrigger`
Define the content of the popover. This should be reference to an \`ng-template\`. Define the open state. Event emitted when the state changes. Define the offset from the trigger element. Define the disabled state. Define the placement of the popover. Define the delay before the popover shows. Define the delay before the popover hides. Define if the popover should flip when it reaches the edge of the viewport. Define the container element for the popover. This is the document body by default. Define whether the popover should close when clicking outside of it. Defines how the popover behaves when the window is scrolled. If set to \`reposition\`, the popover will adjust its position automatically during scrolling. Make sure the popover uses \`position: absolute\` in this mode. If set to \`block\`, scrolling will be disabled while the popover is open. In this case, the popover should use \`position: fixed\`.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-open` | Applied when the popover is open. |
| `data-disabled` | Applied when the popover is disabled. |
Global Configuration
--------------------
You can configure the default options for all popovers in your application by using the `providePopoverConfig` function in a providers array.
import { providePopoverConfig } from 'ng-primitives/popover';
bootstrapApplication(AppComponent, {
providers: [\
providePopoverConfig({\
offset: 4,\
placement: 'top',\
showDelay: 0,\
hideDelay: 0,\
flip: true,\
container: document.body,\
closeOnOutsideClick: true,\
scrollBehavior: 'reposition',\
}),\
],
});
### NgpPopoverConfig
Define the offset from the trigger element. Define the placement of the popover. Define the delay before the popover shows. Define the delay before the popover hides. Define if the popover should flip when it reaches the edge of the viewport. Define the container element for the popover. This is the document body by default. Define whether the popover should close when clicking outside of it. Defines how the popover behaves when the window is scrolled. If set to \`reposition\`, the popover will adjust its position automatically during scrolling. Make sure the popover uses \`position: absolute\` in this mode. If set to \`block\`, scrolling will be disabled while the popover is open. In this case, the popover should use \`position: fixed\`.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Input
=====
The input primitive can be used to enhance the accessibility of an input element and provide consistent interaction handling for hover, focus, press and autofill states.
Import
------
Import the Input primitives from `ng-primitives/input`.
import { NgpInput } from 'ng-primitives/input';
Usage
-----
Assemble the input directives in your template.
Reusable Component
------------------
Create an input component that uses the `NgpInput` directive.
Schematics
----------
Generate a reusable input component using the Angular CLI.
ng g ng-primitives:primitive input
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Input primitive.
### Input Form Field
The input automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/input` package:
### NgpInput
* Selector: `[ngpInput]`
* Exported As: `ngpInput`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocus](/interactions/focus)
, [NgpPress](/interactions/press)
, [NgpAutofill](/utilities/autofill)
#### Data Attributes
The following data attributes are applied to the `ngpInput` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied to the input when hovered. |
| `data-focus` | Applied to the input when focused. |
| `data-disabled` | Applied to the input when disabled. |
| `data-autofill` | Applied to the input when autofilled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Progress
========
Display an indicator representing the progress of a task.
Import
------
Import the Progress primitives from `ng-primitives/progress`.
import { NgpProgress, NgpProgressIndicator } from 'ng-primitives/progress';
Usage
-----
Assemble the avatar directives in your template.
Reusable Component
------------------
Create a reusable component that uses the progress directives.
Schematics
----------
Generate a reusable progress component using the Angular CLI.
ng g ng-primitives:primitive progress
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/progress` package:
### NgpProgress
Apply the `ngpProgress` directive to an element that represents the progress bar.
* Selector: `[ngpProgress]`
* Exported As: `ngpProgress`
Define the progress value. Define the progress max value. Define a function that returns the progress value label.
### NgpProgressIndicator
Apply the `ngpProgressIndicator` directive to an element that represents the current progress. The width of this element can be set to the percentage of the progress value.
* Selector: `[ngpProgressIndicator]`
* Exported As: `ngpProgressIndicator`
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Radio
=====
Selection within a group.
Import
------
Import the Radio primitives from `ng-primitives/radio`.
import { NgpRadioGroup, NgpRadioItem, NgpRadioIndicator } from 'ng-primitives/radio';
Usage
-----
Assemble the radio directives in your template.
Option 1
Option 2
Option 3
Reusable Component
------------------
Create a reusable component that uses the radio directives.
Schematics
----------
Generate a reusable radio component using the Angular CLI.
ng g ng-primitives:primitive radio
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/radio` package:
### NgpRadioGroup
Apply the `ngpRadioGroup` directive to an element that represents the group of radio items.
* Selector: `[ngpRadioGroup]`
* Exported As: `ngpRadioGroup`
* Host Directives: [NgpRovingFocusGroup](/primitives/roving-focus)
, [NgpFormControl](/primitives/form-field)
Define the selected value. Define the disabled state.
Define the orientation.
Event emitted when the selection changes.
### NgpRadioItem
Apply the `ngpRadioItem` directive to an element that represents a radio item. This would typically be a `button` element.
* Selector: `[ngpRadioItem]`
* Exported As: `ngpRadioItem`
* Host Directives: [NgpRovingFocusItem](/primitives/roving-focus)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the value of this item. Define the disabled state.
#### Data Attributes
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. | `-` |
#### Data Attributes
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. |
### NgpRadioIndicator
Apply the `ngpRadioIndicator` directive to an element that represents the radio indicator (i.e. the dot).
* Selector: `[ngpRadioIndicator]`
* Exported As: `ngpRadioIndicator`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpPress](/interactions/press)
#### Data Attributes
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. |
Accessibility
-------------
Adheres to the [Radio Group WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radio)
.
### Keyboard Interaction
* Tab - Moves focus to the first radio button.
* Arrow Down - Moves focus to the next radio button (vertical orientation).
* Arrow Up - Moves focus to the previous radio button (vertical orientation).
* Arrow Right - Moves focus to the next radio button (horizontal orientation).
* Arrow Left - Moves focus to the previous radio button (horizontal orientation).
* Space - Selects the focused radio button if not already selected.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Pagination
==========
The Pagination primitives provide a set of directives to create a pagination control. The pagination control is used to navigate through a set of data that is split into multiple pages.
Import
------
Import the Pagination primitives from `ng-primitives/pagination`.
import {
NgpPagination,
NgpPaginationButton,
NgpPaginationFirst,
NgpPaginationNext,
NgpPaginationPrevious,
NgpPaginationLast,
} from 'ng-primitives/pagination';
Usage
-----
Assemble the pagination directives in your template.
Reusable Component
------------------
Create a reusable component that uses the pagination directives.
Schematics
----------
Generate a reusable pagination component using the Angular CLI.
ng g ng-primitives:primitive pagination
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/pagination` package:
### NgpPagination
The `NgpPagination` directive is used to create a pagination control.
* Selector: `[ngpPagination]`
* Exported As: `ngpPagination`
The current page number. The total number of pages. Emits the new page number when the page changes. Disables the pagination control.
#### Data Attributes
The following data attributes are applied to the `ngpPagination` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-page` | The current page number. | `number` |
| `data-page-count` | The total number of pages. | `number` |
| `data-disabled` | Disables the pagination control. | `boolean` |
| `data-first-page` | Whether the current page is the first page. | `boolean` |
| `data-last-page` | Whether the current page is the last page. | `boolean` |
### NgpPaginationButton
The `NgpPaginationButton` directive is used to create a pagination button.
* Selector: `[ngpPaginationButton]`
* Exported As: `ngpPaginationButton`
* Host Directives: [NgpButton](/primitives/button)
The page number that the button navigates to. Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationButton` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-page` | The page number that the button navigates to. | `number` |
| `data-selected` | Applied when the button is selected. | `-` |
| `data-hover` | Applied when the button is hovered. | `-` |
| `data-focus-visible` | Applied when the button is focused. | `-` |
| `data-press` | Applied when the button is pressed. | `-` |
| `data-disabled` | Disables the pagination button. | `-` |
### NgpPaginationFirst
The `NgpPaginationFirst` directive is used to create a pagination button that navigates to the first page.
* Selector: `[ngpPaginationFirst]`
* Exported As: `ngpPaginationFirst`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationFirst` directive:
| Attribute | Description |
| --- | --- |
| `data-first-page` | Applied when the current page is the first page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpPaginationPrevious
The `NgpPaginationPrevious` directive is used to create a pagination button that navigates to the previous page.
* Selector: `[ngpPaginationPrevious]`
* Exported As: `ngpPaginationPrevious`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationPrevious` directive:
| Attribute | Description |
| --- | --- |
| `data-first-page` | Applied when the current page is the first page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpPaginationNext
The `NgpPaginationNext` directive is used to create a pagination button that navigates to the next page.
* Selector: `[ngpPaginationNext]`
* Exported As: `ngpPaginationNext`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationNext` directive:
| Attribute | Description |
| --- | --- |
| `data-last-page` | Applied when the current page is the last page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
### NgpPaginationLast
The `NgpPaginationLast` directive is used to create a pagination button that navigates to the last page.
* Selector: `[ngpPaginationLast]`
* Exported As: `ngpPaginationLast`
* Host Directives: [NgpButton](/primitives/button)
Disables the pagination button.
#### Data Attributes
The following data attributes are applied to the `ngpPaginationLast` directive:
| Attribute | Description |
| --- | --- |
| `data-last-page` | Applied when the current page is the last page. |
| `data-hover` | Applied when the button is hovered. |
| `data-focus-visible` | Applied when the button is focused. |
| `data-press` | Applied when the button is pressed. |
| `data-disabled` | Applied when the button is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
The search primitive is a form control that allows users to enter a search query and clear the input.
Import
------
Import the Search primitives from `ng-primitives/search`.
import { NgpSearch, NgpSearchClear } from 'ng-primitives/search';
Usage
-----
Assemble the search directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/search` package:
### NgpSearch
The `NgpSearch` directive is a container for the search field components.
* Selector: `[ngpSearch]`
* Exported As: `ngpSearch`
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-empty` | Applied when the input is empty. |
### NgpSearchClear
The `NgpSearchClear` directive is can be added to a button to clear the search field on click.
* Selector: `[ngpSearchClear]`
* Exported As: `ngpSearchClear`
| Attribute | Description |
| --- | --- |
| `data-empty` | Applied when the search field is empty. |
Accessibility
-------------
Adheres to the [Search WAI-ARIA design pattern](https://www.w3.org/TR/wai-aria-1.2/#searchbox)
.
### Keyboard Interaction
* Esc - Clears the search field.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Select
======
A select is a form control that allows users to select options from a list. This primitive enhances the native select element with improved accessibility and interaction handling for hover and focus.
Import
------
Import the Select primitives from `ng-primitives/select`.
import { NgpSelect } from 'ng-primitives/select';
Usage
-----
Assemble the select directives in your template.
24 hours
12 hours
Examples
--------
Here are some additional examples of how to use the Select primitives.
### Select Form Field
The select automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/select` package:
### NgpSelect
Apply the `ngpSelect` directive to a select element that you want to enhance.
* Selector: `[ngpSelect]`
* Exported As: `ngpSelect`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the disabled state.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the element is hovered. |
| `data-focus-visible` | Applied when the element is focused. |
| `data-disabled` | Applied when the element is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Separator
=========
The separator primitive allow you to semantically separate content either horizontally or vertically.
Import
------
Import the Separator primitives from `ng-primitives/separator`.
import { NgpSeparator } from 'ng-primitives/separator';
Usage
-----
Assemble the separator directives in your template.
Reusable Component
------------------
Create a reusable component that uses the `NgpSeparator` directive.
Schematics
----------
Generate a reusable separator component using the Angular CLI.
ng g ng-primitives:primitive separator
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/separator` package:
### NgpSeparator
* Selector: `[ngpSeparator]`
* Exported As: `ngpSeparator`
The orientation of the separator.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-orientation` | The orientation of the separator. |
Global Configuration
--------------------
You can configure the default options for all separators in your application by using the `provideSeparatorConfig` function in a providers array.
import { provideSeparatorConfig } from 'ng-primitives/tabs';
bootstrapApplication(AppComponent, {
providers: [\
provideSeparatorConfig({\
orientation: 'horizontal',\
}),\
],
});
### NgpSeparatorConfig
The following options are available to configure the default tab options:
Define the default orientation of the separator. Accessibility
Adheres to the [WAI-ARIA Separator Design Pattern](https://www.w3.org/TR/wai-aria-1.2/#separator)
.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Resize
======
Perform actions on element resize.
Import
------
Import the Resize primitive from `ng-primitives/resize`.
import { NgpResize } from 'ng-primitives/resize';
Usage
-----
Assemble the resize directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/resize` package:
### NgpResize
Apply the `ngpResize` directive to an element to listen for resize events.
* Selector: `[ngpResize]`
* Exported As: `ngpResize`
Event emitted when the element is resize.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Roving Focus
============
Handle focus for a group of elements.
Import
------
Import the Roving Focus primitives from `ng-primitives/roving-focus`.
import { NgpRovingFocusGroup, NgpRovingFocusItem } from 'ng-primitives/roving-focus';
Usage
-----
Assemble the roving focus directives in your template.
Item 1
Item 2
Item 3
API Reference
-------------
The following directives are available to import from the `ng-primitives/roving-focus` package:
### NgpRovingFocusGroup
Apply the `ngpRovingFocusGroup` directive to an element to manage focus for a group of child elements.
* Selector: `[ngpRovingFocusGroup]`
* Exported As: `ngpRovingFocusGroup`
Define the orientation of the roving focus group. Define whether the focus should wrap around the group. Define whether the focus should move to the first or last element when pressing the Home or End key. Define whether the roving focus group is disabled.
### NgpRovingFocusItem
Apply the `ngpRovingFocusItem` directive to an element within a roving focus group to automatically manage focus.
* Selector: `[ngpRovingFocusItem]`
* Exported As: `ngpRovingFocusItem`
Define whether the roving focus item is disabled.
Accessibility
-------------
Adheres to the [WAI-ARIA Keyboard Interface Practices](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/)
.
### Keyboard Interactions
* Tab - Move focus to the first item.
* ArrowLeft - Move focus to the previous item (horizontal orientation).
* ArrowUp - Move focus to the previous item (vertical orientation).
* ArrowRight - Move focus to the next item (horizontal orientation).
* ArrowDown - Move focus to the next item (vertical orientation).
* Home - Move focus to the first item.
* End - Move focus to the last item.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Switch
======
Perform state toggling.
Import
------
Import the Switch primitives from `ng-primitives/switch`.
import { NgpSwitch, NgpSwitchThumb } from 'ng-primitives/switch';
Usage
-----
Assemble the switch directives in your template.
Reusable Component
------------------
Create a reusable component that uses the switch directives.
Schematics
----------
Generate a reusable switch component using the Angular CLI.
ng g ng-primitives:primitive switch
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Switch primitives.
### Switch Form Field
The switch automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/switch` package:
### NgpSwitch
Apply the `ngpSwitch` directive to an element to manage the checked state.
* Selector: `[ngpSwitch]`
* Exported As: `ngpSwitch`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the checked state. Define the disabled state. Event emitted when the state changes.
#### Data Attributes
The following data attributes are applied to the `ngpSwitch` directive:
| Attribute | Description |
| --- | --- |
| `data-checked` | Applied when the switch is checked. |
| `data-disabled` | Applied when the switch is disabled. |
| `data-hover` | Applied when the switch is hovered. |
| `data-focus-visible` | Applied when the switch is focused. |
| `data-press` | Applied when the switch is pressed. |
### NgpSwitchThumb
Apply the `ngpSwitchThumb` directive to an element within a switch to represent the thumb.
* Selector: `[ngpSwitchThumb]`
* Exported As: `ngpSwitchThumb`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
#### Data Attributes
The following data attributes are available to style the thumb:
| Attribute | Description |
| --- | --- |
| `data-checked` | Applied when the switch is checked. |
| `data-disabled` | Applied when the switch is disabled. |
| `data-hover` | Applied when the switch thumb is hovered. |
| `data-focus-visible` | Applied when the switch thumb is focused. |
| `data-press` | Applied when the switch thumb is pressed. |
Accessibility
-------------
Adheres to the [WAI-ARIA switch design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/)
.
### Keyboard Interactions
* Space - Toggle the switch state.
* Enter - Toggle the switch state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Slider
======
Select a value within a range.
Import
------
Import the Slider primitives from `ng-primitives/slider`.
import { NgpSlider, NgpSliderTrack, NgpSliderRange, NgpSliderThumb } from 'ng-primitives/slider';
Usage
-----
Assemble the slider directives in your template.
Reusable Component
------------------
Create a reusable component that uses the slider directives.
Schematics
----------
Generate a reusable slider component using the Angular CLI.
ng g ng-primitives:primitive slider
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Slider primitives.
### Slider Form Field
The slider automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/slider` package:
### NgpSlider
Apply the `ngpSlider` directive to an element that represents the slider and contains the track, range, and thumb.
* Selector: `[ngpSlider]`
* Exported As: `ngpSlider`
* Host Directives: [NgpFormControl](/primitives/form-field)
Define the selected value. Define the minimum value. Define the maximum value. Define the step value. Define the orientation.
#### Data Attributes
The following data attributes are available to style the slider:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
### NgpSliderTrack
Apply the `ngpSliderTrack` directive to an element that represents the track of the slider.
* Selector: `[ngpSliderTrack]`
* Exported As: `ngpSliderTrack`
#### Data Attributes
The following data attributes are available to style the slider track:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
### NgpSliderRange
Apply the `ngpSliderRange` directive to an element that represents the range of the slider.
* Selector: `[ngpSliderRange]`
* Exported As: `ngpSliderRange`
#### Data Attributes
The following data attributes are available to style the slider range:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
### NgpSliderThumb
Apply the `ngpSliderThumb` directive to an element that represents the thumb of the slider.
* Selector: `[ngpSliderThumb]`
* Exported As: `ngpSliderThumb`
* Host Directives: [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
#### Data Attributes
The following data attributes are available to style the thumb:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the slider. | `horizontal` \| `vertical` |
| `data-disabled` | Applied when the slider is disabled. | `-` |
| `data-hover` | Applied when the slider thumb is hovered. | `-` |
| `data-focus-visible` | Applied when the slider thumb is focused. | `-` |
| `data-press` | Applied when the slider thumb is pressed. | `-` |
Accessibility
-------------
Adheres to the [Slider WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb)
.
### Keyboard Interactions
* Left Arrow or Down Arrow: Decrease the value by the step.
* Right Arrow or Up Arrow: Increase the value by the step.
* Left Arrow or Down Arrow + Shift: Decrease the value by the step by a larger amount.
* Right Arrow or Up Arrow + Shift: Increase the value by the step by a larger amount.
* Home: Set the value to the minimum.
* End: Set the value to the maximum.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Tabs
====
Dynamically show and hide content based on an active tab.
Import
------
Import the Tabs primitives from `ng-primitives/tabs`.
import { NgpTabset, NgpTabList, NgpTabButton, NgpTabPanel } from 'ng-primitives/tabs';
Usage
-----
Assemble the tabs directives in your template.
Tab 1
Tab 2
Tab 3
Tab 1 content
Tab 2 content
Tab 3 content
Reusable Component
------------------
Create reusable components that uses the tab directives.
Schematics
----------
Generate a reusable tab components using the Angular CLI.
ng g ng-primitives:primitive tabs
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/tabs` package:
### NgpTabset
Apply the `ngpTabset` directive to an element to manage the tabs.
* Selector: `[ngpTabset]`
* Exported As: `ngpTabset`
* Host Directives: [NgpRovingFocusGroup](/primitives/roving-focus)
Define the selected tab. Define the orientation of the tabs. Define whether the tab should activate on focus.
#### Data Attributes
The following data attributes are applied to the `ngpTabset` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
### NgpTabList
Apply the `ngpTabList` directive to an element that represents the list of tab buttons.
* Selector: `[ngpTabList]`
* Exported As: `ngpTabList`
#### Data Attributes
The following data attributes are applied to the `ngpTabList` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
### NgpTabButton
Apply the `ngpTabButton` directive to an element within a tab list to represent a tab button. This directive should be applied to a button element.
* Selector: `[ngpTabButton]`
* Exported As: `ngpTabButton`
* Host Directives: [NgpRovingFocusItem](/primitives/roving-focus)
, [NgpHover](/interactions/hover)
, [NgpFocusVisible](/interactions/focus-visible)
, [NgpPress](/interactions/press)
Define the value of the tab. Define whether the tab button is disabled.
#### Data Attributes
The following data attributes are applied to the `ngpTabButton` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
| `data-active` | Applied when the tab is active. | `-` |
| `data-disabled` | Applied when the tab is disabled. | `-` |
| `data-hover` | Applied when the tab is hovered. | `-` |
| `data-focus-visible` | Applied when the tab is focused. | `-` |
| `data-press` | Applied when the tab is pressed. | `-` |
### NgpTabPanel
Apply the `ngpTabPanel` directive to an element that represents the content of a tab.
* Selector: `[ngpTabPanel]`
* Exported As: `ngpTabPanel`
Define the value of the tab.
#### Data Attributes
The following data attributes are applied to the `ngpTabPanel` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-active` | Applied when the tab is active. | `-` |
| `data-orientation` | The orientation of the tabs. | `horizontal` \| `vertical` |
Global Configuration
--------------------
You can configure the default options for all tabs in your application by using the `provideTabsConfig` function in a providers array.
import { provideTabsConfig } from 'ng-primitives/tabs';
bootstrapApplication(AppComponent, {
providers: [\
provideTabsConfig({\
orientation: 'horizontal',\
activateOnFocus: false,\
wrap: false,\
}),\
],
});
### NgpTabsConfig
The following options are available to configure the default tab options:
Define the default orientation of the tabs. Define whether the tab should activate on focus. Define whether the tabs should wrap around the tab list.
Accessibility
-------------
Adheres to the [Tabs WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs)
.
### Keyboard Interactions
* ArrowLeft: Move focus to the previous tab (horizontal orientation).
* ArrowRight: Move focus to the next tab (horizontal orientation).
* ArrowUp: Move focus to the previous tab (vertical orientation).
* ArrowDown: Move focus to the next tab (vertical orientation).
* Home: Move focus to the first tab.
* End: Move focus to the last tab.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toast
=====
A toast is a non-modal, unobtrusive window element used to display brief, auto-expiring messages to the user.
Import
------
Import the Toast primitives from `ng-primitives/toast`.
import { NgpToast } from 'ng-primitives/toast';
Usage
-----
Assemble the toast directives in your template.
Show Toast
...
To show a toast, call the `show` method on the `ngpToast` directive.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toast` package:
The duration in milliseconds that the toast will be visible. The position of the toast. The gravity of the toast. This will determine the location the toast will slide in and out. Whether the toast should stop the timer when hovered over. Once the mouse leaves the toast, the timer will restart. The \`aria-live\` attribute value for the toast. This will determine how the toast will be read by screen readers.
### NgpToast
* Selector: `[ngpToast]`
* Exported As: `ngpToast`
#### Data Attributes
The following data attributes are applied to the first child of the `ngpToast` ng-template:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-toast` | The visible state of the toast. | `visible` \| `hidden` |
| `data-position` | The position of the toast. | `start` \| `center` \| `end` |
| `data-gravity` | The gravity of the toast. | `top` \| `bottom` |
Global Configuration
--------------------
You can configure the default options for all toasts in your application by using the `provideToastConfig` function in a providers array.
import { provideToastConfig } from 'ng-primitives/toast';
bootstrapApplication(AppComponent, {
providers: [\
provideToastConfig({\
duration: 5000,\
position: 'center',\
gravity: 'top',\
stopOnHover: false,\
ariaLive: 'assertive',\
gap: 16,\
}),\
],
});
### NgpToastConfig
The duration in milliseconds that the toast will be visible. The position of the toast. The gravity of the toast. This will determine the location the toast will slide in and out. Whether the toast should stop the timer when hovered over. Once the mouse leaves the toast, the timer will restart. The \`aria-live\` attribute value for the toast. This will determine how the toast will be read by screen readers. The gap between each toast.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Textarea
========
The textarea primitive can be used to enhance the accessibility of a textarea element and provide consistent interaction handling for hover, focus and press states.
Import
------
Import the Textarea primitives from `ng-primitives/textarea`.
import { NgpTextarea } from 'ng-primitives/textarea';
Usage
-----
Assemble the textarea directives in your template.
Reusable Component
------------------
Create an textarea component that uses the `NgpTextarea` directive.
Schematics
----------
Generate a reusable textarea component using the Angular CLI.
ng g ng-primitives:primitive textarea
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Textarea primitive.
### Textarea Form Field
The textarea automatically integrates with the form field primitives.
API Reference
-------------
The following directives are available to import from the `ng-primitives/textarea` package:
### NgpTextarea
* Selector: `[ngpTextarea]`
* Exported As: `ngpTextarea`
* Host Directives: [NgpFormControl](/primitives/form-field)
, [NgpHover](/interactions/hover)
, [NgpFocus](/interactions/focus)
, [NgpPress](/interactions/press)
#### Data Attributes
The following data attributes are applied to the `ngpTextarea` directive:
| Attribute | Description |
| --- | --- |
| `data-hover` | Applied when the element is hovered. |
| `data-focus` | Applied when the element is focused. |
| `data-disabled` | Applied when the element is disabled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toggle
======
Toggle a button on and off.
Import
------
Import the Toggle primitives from `ng-primitives/toggle`.
import { NgpToggle } from 'ng-primitives/toggle';
Usage
-----
Assemble the toggle directives in your template.
Toggle
Reusable Component
------------------
Create a reusable component that uses the toggle directives.
Schematics
----------
Generate a reusable toggle component using the Angular CLI.
ng g ng-primitives:primitive toggle
### Options
* `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`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toggle` package:
### NgpToggle
Apply the `ngpToggle` directive to an element to manage the toggle state. This must be applied to a `button` element.
* Selector: `[ngpToggle]`
* Exported As: `ngpToggle`
Define the selected state. Define the disabled state. Event emitted when the selected state changes.
#### Data Attributes
The following data attributes are applied to the `ngpToggle` directive:
| Attribute | Description |
| --- | --- |
| `data-selected` | Applied when the toggle is selected. |
| `data-disabled` | Applied when the toggle is disabled. |
Accessibility
-------------
### Keyboard Interaction
* Space: Toggles the selected state.
* Enter: Toggles the selected state.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Tooltip
=======
Display additional information on hover.
Import
------
Import the Tooltip primitives from `ng-primitives/tooltip`.
import { NgpTooltip } from 'ng-primitives/tooltip';
Usage
-----
Assemble the tooltip directives in your template.
Hover me
Tooltip content
API Reference
-------------
The following directives are available to import from the `ng-primitives/tooltip` package:
### NgpTooltip
Apply the `ngpTooltip` directive to an element that represents the tooltip. This typically would be a `div` inside an `ng-template`.
* Selector: `[ngpTooltip]`
* Exported As: `ngpTooltip`
### NgpTooltipTrigger
Apply the `ngpTooltipTrigger` directive to an element that triggers the tooltip to show.
* Selector: `[ngpTooltipTrigger]`
* Exported As: `ngpTooltipTrigger`
Define the content of the tooltip. This should be reference to an \`ng-template\`. Define the open state. Event emitted when the state changes. Define the offset from the trigger element. Define the disabled state. Define the placement of the tooltip. Define the delay before the tooltip shows. Define the delay before the tooltip hides. Define if the tooltip should flip when it reaches the edge of the viewport. Define the container element for the tooltip. This is the document body by default.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-open` | Applied when the popover is open. |
| `data-disabled` | Applied when the tooltip is disabled. |
Global Configuration
--------------------
You can configure the default options for all tooltips in your application by using the `provideTooltipConfig` function in a providers array.
import { provideTooltipConfig } from 'ng-primitives/tooltip';
bootstrapApplication(AppComponent, {
providers: [\
provideTooltipConfig({\
offset: 4,\
placement: 'top',\
showDelay: 0,\
hideDelay: 0,\
flip: true,\
container: document.body,\
}),\
],
});
### NgpTooltipConfig
Define the offset from the trigger element. Define the placement of the tooltip. Define the delay before the tooltip shows. Define the delay before the tooltip hides. Define if the tooltip should flip when it reaches the edge of the viewport. Define the container element for the tooltip. This is the document body by default.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toolbar
=======
The Toolbar primitive is a container for grouping related controls.
Import
------
Import the Toolbar primitives from `ng-primitives/toolbar`.
import { NgpToolbar } from 'ng-primitives/toolbar';
Usage
-----
Assemble the toolbar directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toolbar` package:
### NgpToolbar
* Selector: `[ngpToolbar]`
* Exported As: `ngpToolbar`
The orientation of the toolbar.
#### Data Attributes
The following data attributes are applied to the `ngpToolbar` directive:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-orientation` | The orientation of the toolbar. | `horizontal` \| `vertical` |
Accessibility
-------------
Adheres to the [WAI-ARIA Toolbar Design Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar)
.
### Keyboard Interaction
* Tab - Moves focus to the first interactive element in the toolbar.
* Arrow Down - Moves focus to the next interactive element (vertical orientation).
* Arrow Up - Moves focus to the previous interactive element (vertical orientation).
* Arrow Right - Moves focus to the next interactive element (horizontal orientation).
* Arrow Left - Moves focus to the previous interactive element (horizontal orientation).
* Home - Moves focus to the first interactive element in the toolbar.
* End - Moves focus to the last interactive element in the toolbar.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Primitives
Toggle Group
============
The toggle group primitive is a collection of toggle buttons that can be used to select one or more options.
Import
------
Import the ToggleGroup primitives from `ng-primitives/toggle-group`.
import { NgpToggleGroup, NgpToggleGroupItem } from 'ng-primitives/toggle-group';
Usage
-----
Assemble the toggle-group directives in your template.
Option 1
Option 2
Option 3
Reusable Component
------------------
Create a reusable component that uses the toggle group directives.
Schematics
----------
Generate a reusable toggle group component using the Angular CLI.
ng g ng-primitives:primitive toggle-group
### Options
* `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`.
Examples
--------
Here are some additional examples of how to use the Toggle Group primitives.
### Multiple Selection
The toggle group can be configured to allow multiple selections by setting the `ngpToggleGroupType` input to `multiple`.
API Reference
-------------
The following directives are available to import from the `ng-primitives/toggle-group` package:
### NgpToggleGroup
* Selector: `[ngpToggleGroup]`
* Exported As: `ngpToggleGroup`
The orientation of the toggle group. he selected value(s) of the toggle group. The type of the toggle group, whether only one item can be selected or multiple. Whether the toggle group is disabled.
#### Data Attributes
The following data attributes are available to style the toggle group:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the toggle group is disabled. | `-` |
| `data-orientation` | The orientation of the toggle group. | `horizontal` \| `vertical` |
| `data-type` | The type of the toggle group. | `single` \| `multiple` |
### NgpToggleGroupItem
* Selector: `[ngpToggleGroupItem]`
* Exported As: `ngpToggleGroupItem`
The value of the toggle group item. Whether the toggle group item is disabled.
#### Data Attributes
The following data attributes are available to style the toggle group item:
| Attribute | Description | Value |
| --- | --- | --- |
| `data-disabled` | Applied when the toggle group item is disabled. | `-` |
| `data-selected` | Applied when the toggle group item is selected. | `-` |
Global Configuration
--------------------
You can configure the default options for all toggle-groups in your application by using the `provideToggleGroupConfig` function in a providers array.
import { provideToggleGroupConfig } from 'ng-primitives/toggle-group';
bootstrapApplication(AppComponent, {
providers: [\
provideToggleGroupConfig({\
orientation: 'vertical',\
type: 'multiple',\
}),\
],
});
### NgpToggleGroupConfig
The default orientation of the toggle group. The default type of the toggle group.
### Keyboard Interaction
* Tab - Moves focus to the first toggle group item in the toolbar.
* Arrow Down - Moves focus to the next toggle group item (vertical orientation).
* Arrow Up - Moves focus to the previous toggle group item (vertical orientation).
* Arrow Right - Moves focus to the next toggle group item (horizontal orientation).
* Arrow Left - Moves focus to the previous toggle group item (horizontal orientation).
* Home - Moves focus to the first toggle group item.
* End - Moves focus to the last toggle group item.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Focus
=====
Normalizes the focus event across different browsers and devices.
Import
------
Import the Focus primitives from `ng-primitives/interactions`.
import { NgpFocus } from 'ng-primitives/interactions';
Usage
-----
Assemble the focus directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpFocus
* Selector: `[ngpFocus]`
* Exported As: `ngpFocus`
Whether listening for focus events is disabled. Event emitted when the focus state changes.
#### Data Attributes
The following data attributes are applied to the `ngpFocus` directive:
| Attribute | Description |
| --- | --- |
| `data-focus` | Applied when the element is focused. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Focus Visible
=============
Determine whether focus should be visible based on user interaction. This is useful for accessibility and user experience, as it allows you to provide visual feedback when an element is focused using keyboard navigation, while not showing the focus outline when the user is using a mouse or touch device.
Import
------
Import the Focus Visible primitives from `ng-primitives/interactions`.
import { NgpFocusVisible } from 'ng-primitives/interactions';
Usage
-----
Assemble the focus-visible directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpFocusVisible
* Selector: `[ngpFocusVisible]`
* Exported As: `ngpFocusVisible`
Whether listening for focus-visible events is disabled. Event emitted when the focus visible state changes.
#### Data Attributes
The following data attributes are applied to the `ngpFocusVisible` directive:
| Attribute | Description |
| --- | --- |
| `data-focus-visible` | Applied when the element is focused via keyboard navigation. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Hover
=====
Normalizes the hover event across different browsers and devices.
Import
------
Import the Hover primitive from `ng-primitives/interactions`.
import { NgpHover } from 'ng-primitives/interactions';
Usage
-----
Assemble the hover directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpHover
* Selector: `[ngpHover]`
* Exported As: `ngpHover`
Apply the `ngpHover` directive to an element that you want to listen for hover events. This is particulaly useful for supporting hover events on touch devices, where hover events are not handled consistently. On iOS relying on the `:hover` pseudo-class can result in the hover state being stuck until the user taps elsewhere on the screen.
Event emitted when the hover state changes. Event emitted when the hover starts. Event emitted when the hover ends. Whether hover events are disabled.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-hover` | Added to the element when hovering occurs. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Press
=====
Normalizes the press event across different browsers and devices.
Import
------
Import the Press primitives from `ng-primitives/interactions`.
import { NgpPress } from 'ng-primitives/interactions';
Usage
-----
Assemble the press directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpPress
The `ngpPress` directive listens for press events on an element. This is particularly useful for supporting press events on touch devices, where press events are not handled consistently.
* Selector: `[ngpPress]`
* Exported As: `ngpPress`
Event emitted when the press state changes. Whether press events are disabled. Event emitted when the press starts. Event emitted when the press ends.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-press` | Applied when the element is being pressed. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Interactions
Move
====
The Move primitives enable pointer and keyboard move interactions on an element.
Import
------
Import the Move primitives from `ng-primitives/interactions`.
import { NgpMove } from 'ng-primitives/interactions';
Usage
-----
Assemble the move directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/interactions` package:
### NgpMove
The `NgpMove` directive is used to enable the pointer and keyboard move interactions on an element.
* Selector: `[ngpMove]`
* Exported As: `ngpMove`
Disables the move interaction. Emits when the move interaction starts. Emits when the move interaction is in progress. Emits when the move interaction ends.
#### Data Attributes
The following data attributes are available to use with the `NgpMove` directive:
| Attribute | Description |
| --- | --- |
| `data-move` | Applied when the element is being moved. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Autofill
========
Detect autofill events on input elements. This can be useful for styling or behavior changes when the browser autofills an input. Floating labels are a common use case for this directive.
Import
------
Import the Autofill primitives from `ng-primitives/autofill`.
import { NgpAutofill } from 'ng-primitives/autofill';
Usage
-----
Assemble the autofill directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/autofill` package:
### NgpAutofill
* Selector: `[ngpAutofill]`
* Exported As: `ngpAutofill`
Event emitted when the autofill state changes.
#### Data Attributes
The following data attributes are applied to the `ngpAutofill` directive:
| Attribute | Description |
| --- | --- |
| `data-autofill` | Applied when the element is autofilled. |
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Focus Trap
==========
The Focus Trap utility is a directive that traps focus within a specified element. This is useful for modals, dropdowns, and other components that require focus to be contained within a specific area.
Import
------
Import the FocusTrap primitives from `ng-primitives/focus-trap`.
import { NgpFocusTrap } from 'ng-primitives/focus-trap';
Usage
-----
Assemble the focus-trap directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/focus-trap` package:
### NgpFocusTrap
The `NgpFocusTrap` directive traps focus within the host element.
* Selector: `[ngpFocusTrap]`
* Exported As: `ngpFocusTrap`
Disables the focus trap.
#### Data Attributes
| Attribute | Description |
| --- | --- |
| `data-focus-trap` | Applied when focus is trapped. |
Accessibility
-------------
Adheres to the [WAI-ARIA design pattern](https://www.w3.org/TR/UNDERSTANDING-WCAG20/keyboard-operation-trapping.html)
.
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Date Adapter
============
The Date Adapter is an abstraction layer that allows components to use date objects from any date library, ensuring compatibility and easy integration.
Import
------
Import the DateAdapter from `ng-primitives/date-time`.
import { NgpLuxonDateAdapter } from 'ng-primitives/date-time-lucon';
import { NgpDateAdapter, NgpNativeDateAdapter } from 'ng-primitives/date-time-luxon';
Usage
-----
Angular Primitives ships with two date adapters out of the box: `NgpNativeDateAdapter` and `NgpLuxonDateAdapter`. The `NgpNativeDateAdapter` uses the native JavaScript `Date` object, while the `NgpLuxonDateAdapter` uses the Luxon date library.
To use a date adapter, you need to provide it to Angular's dependency injection system. This can be done once at the root of your application or at a component/module level.
bootstrapApplication(AppComponent, {
providers: [provideDateAdapter(NgpLuxonDateAdapter)],
});
If no date adapter is provided, the `NgpNativeDateAdapter` will be used by default.
Should you need to use a different date library, you can create your own date adapter by implementing the `NgpDateAdapter` interface.
Should you wish to use the adapter in a component, you can inject it into a component.
import { Component } from '@angular/core';
import { DateTime } from 'luxon';
import { injectDateAdapter } from 'ng-primitives/date-time';
@Component({
selector: 'app-root',
template: `
...
`,
})
export class AppComponent {
private readonly dateAdapter = injectDateAdapter();
}
API Reference
-------------
All date adapters must implement the `NgpDateAdapter` interface.
interface NgpDateAdapter {
/**
* Create a new date time object.
*/
create(values: NgpDateUnits): T;
/**
* Create a new date with the current date and time.
*/
now(): T;
/**
* Set the year of the date time object based on a duration.
*/
set(date: T, values: NgpDateUnits): T;
/**
* Add a duration to the date time object.
*/
add(date: T, duration: NgpDuration): T;
/**
* Subtract a duration from the date time object.
*/
subtract(date: T, duration: NgpDuration): T;
/**
* Compare two date time objects.
*/
compare(a: T, b: T): number;
/**
* Determine if two date time objects are equal.
*/
isEqual(a: T, b: T): boolean;
/**
* Determine if a date time object is before another.
*/
isBefore(a: T, b: T): boolean;
/**
* Determine if a date time object is after another.
*/
isAfter(a: T, b: T): boolean;
/**
* Determine if two date objects are on the same day.
*/
isSameDay(a: T, b: T): boolean;
/**
* Determine if two date objects are on the same month.
*/
isSameMonth(a: T, b: T): boolean;
/**
* Determine if two date objects are on the same year.
*/
isSameYear(a: T, b: T): boolean;
/**
* Get the year.
*/
getYear(date: T): number;
/**
* Get the month.
*/
getMonth(date: T): number;
/**
* Get the date.
*/
getDate(date: T): number;
/**
* Get the day.
*/
getDay(date: T): number;
/**
* Get the hours.
*/
getHours(date: T): number;
/**
* Get the minutes.
*/
getMinutes(date: T): number;
/**
* Get the seconds.
*/
getSeconds(date: T): number;
/**
* Get the milliseconds.
*/
getMilliseconds(date: T): number;
/**
* Get the first day of the month.
*/
startOfMonth(date: T): T;
/**
* Get the last day of the month.
*/
endOfMonth(date: T): T;
/**
* Get the start of the day.
*/
startOfDay(date: T): T;
/**
* Get the end of the day.
*/
endOfDay(date: T): T;
}
On this page
------------
Copyright © 2025 Angular Primitives
---
# Angular Primitives
Getting Started
---------------
* [Introduction](/getting-started/introduction)
* [Get Started](/getting-started/get-started)
* [Styling](/getting-started/styling)
* [Usage](/getting-started/usage)
Primitives
----------
* [Accordion](/primitives/accordion)
* [Avatar](/primitives/avatar)
* [Button](/primitives/button)
* [Checkbox](/primitives/checkbox)
* [Date Picker](/primitives/date-picker)
* [Dialog](/primitives/dialog)
* [File Upload](/primitives/file-upload)
* [Form Field](/primitives/form-field)
* [Icons](/primitives/icons)
* [Input](/primitives/input)
* [Listbox](/primitives/listbox)
* [Menu](/primitives/menu)
* [Pagination](/primitives/pagination)
* [Popover](/primitives/popover)
* [Progress](/primitives/progress)
* [Radio](/primitives/radio)
* [Resize](/primitives/resize)
* [Roving Focus](/primitives/roving-focus)
* [Search](/primitives/search)
* [Select](/primitives/select)
* [Separator](/primitives/separator)
* [Slider](/primitives/slider)
* [Switch](/primitives/switch)
* [Tabs](/primitives/tabs)
* [Textarea](/primitives/textarea)
* [Toast](/primitives/toast)
* [Toggle Group](/primitives/toggle-group)
* [Toggle](/primitives/toggle)
* [Toolbar](/primitives/toolbar)
* [Tooltip](/primitives/tooltip)
Interactions
------------
* [Focus Visible](/interactions/focus-visible)
* [Focus](/interactions/focus)
* [Hover](/interactions/hover)
* [Move](/interactions/move)
* [Press](/interactions/press)
Utilities
---------
* [Autofill](/utilities/autofill)
* [Date Adapter](/utilities/date-adapter)
* [Focus Trap](/utilities/focus-trap)
* [Visually Hidden](/utilities/visually-hidden)
Utilities
Visually Hidden
===============
Hide an element visually while keeping it present in the DOM. This is particularly useful for accessibility purposes, ensuring that screen readers and other assistive technologies can still interact with the hidden content.
Import
------
Import the VisuallyHidden primitives from `ng-primitives/a11y`.
import { NgpVisuallyHidden } from 'ng-primitives/a11y';
Usage
-----
Assemble the visually-hidden directives in your template.
API Reference
-------------
The following directives are available to import from the `ng-primitives/a11y` package:
### NgpVisuallyHidden
Hide an element visually while keeping it present in the DOM.
* Selector: `[ngpVisuallyHidden]`
* Exported As: `ngpVisuallyHidden`
Accessibility
-------------
This directive can be useful for hiding content that is still important for screen readers and other assistive technologies.
On this page
------------
Copyright © 2025 Angular Primitives
---