# PrimeNG Documentation Generated: 2025-12-04 --- # Guide Pages # Installation Setting up PrimeNG in an Angular CLI project. ## Download PrimeNG is available for download on the npm registry . ## Examples An example starter with Angular CLI is available at GitHub . ## Nextsteps Welcome to the Prime UI Ecosystem! Once you have PrimeNG up and running, we recommend exploring the following resources to gain a deeper understanding of the library. Global configuration Customization of styles Getting support ## Provider Add providePrimeNG to the list of providers in your app.config.ts and use the theme property to configure a theme such as Aura.
TypeScript Example ```typescript import { ApplicationConfig } from '@angular/core'; import { providePrimeNG } from 'primeng/config'; import Aura from '@primeuix/themes/aura'; export const appConfig: ApplicationConfig = { providers: [ providePrimeNG({ theme: { preset: Aura } }) ] }; ```
## Verify Verify your setup by adding a component such as Button. Each component can be imported and registered individually so that you only include what you use for bundle optimization. Import path is available in the documentation of the corresponding component. ## Videos Angular CLI is the recommended way to build Angular applications with PrimeNG. --- # Configuration Application wide configuration for PrimeNG. ## Csp The nonce value to use on dynamically generated style elements in core.
TypeScript Example ```typescript providePrimeNG({ csp: { nonce: '...' } }) ```
## Dynamic Inject the PrimeNG to your application to update the initial configuration at runtime.
TypeScript Example ```typescript import { Component, OnInit } from '@angular/core'; import { PrimeNG } from 'primeng/config'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent implements OnInit { constructor(private primeng: PrimeNG) {} ngOnInit() { this.primeng.ripple.set(true); } } ```
## Filtermode Default filter modes to display on DataTable filter menus.
TypeScript Example ```typescript providePrimeNG({ filterMatchModeOptions: { text: [FilterMatchMode.STARTS_WITH, FilterMatchMode.CONTAINS, FilterMatchMode.NOT_CONTAINS, FilterMatchMode.ENDS_WITH, FilterMatchMode.EQUALS, FilterMatchMode.NOT_EQUALS], numeric: [FilterMatchMode.EQUALS, FilterMatchMode.NOT_EQUALS, FilterMatchMode.LESS_THAN, FilterMatchMode.LESS_THAN_OR_EQUAL_TO, FilterMatchMode.GREATER_THAN, FilterMatchMode.GREATER_THAN_OR_EQUAL_TO], date: [FilterMatchMode.DATE_IS, FilterMatchMode.DATE_IS_NOT, FilterMatchMode.DATE_BEFORE, FilterMatchMode.DATE_AFTER] } }) ```
## Inputvariant Input fields come in two styles, default is outlined with borders around the field whereas filled alternative adds a background color to the field. A theme such as Material may add more additional design changes per each variant.
TypeScript Example ```typescript providePrimeNG({ inputVariant: 'filled' }) ```
## Api Locale Options ## Repository Ready to use settings for locales are available at the community supported PrimeLocale repository. We'd appreciate if you could contribute to this repository with pull requests and share it with the rest of the community. ## Runtime The translations can be changed dynamically at runtime, here is an example with ngx-translate.
TypeScript Example ```typescript import { Component, OnInit } from '@angular/core'; import { PrimeNG } from 'primeng/config'; import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent implements OnInit { constructor(private config: PrimeNG, private translateService: TranslateService) {} ngOnInit() { this.translateService.setDefaultLang('en'); } translate(lang: string) { this.translateService.use(lang); this.translateService.get('primeng').subscribe(res => this.primeng.setTranslation(res)); } } ```
## Translation A translation is specified using the translation property during initialization.
TypeScript Example ```typescript providePrimeNG({ translation: { accept: 'Aceptar', reject: 'Rechazar', //translations } }) ```
## Provider The initial configuration is defined by the providePrimeNG provider during application startup.
TypeScript Example ```typescript import { ApplicationConfig } from '@angular/core'; import { providePrimeNG } from 'primeng/config'; export const appConfig: ApplicationConfig = { providers: [ providePrimeNG({ /* options */ }) ] }; ```
## Ripple Ripple is an optional animation for the supported components such as buttons. It is disabled by default.
TypeScript Example ```typescript providePrimeNG({ ripple: true }) ```
## Theme PrimeNG provides 4 predefined themes out of the box; Aura, Material, Lara and Nora. See the theming documentation for details.
TypeScript Example ```typescript import { ApplicationConfig } from '@angular/core'; import { providePrimeNG } from 'primeng/config'; import Aura from '@primeuix/themes/aura'; export const appConfig: ApplicationConfig = { providers: [ providePrimeNG({ theme: { preset: Aura, options: { prefix: 'p', darkModeSelector: 'system', cssLayer: false } } }) ] }; ```
## Zindex ZIndexes are managed automatically to make sure layering of overlay components work seamlessly when combining multiple components. Still there may be cases where you'd like to configure the configure default values such as a custom layout where header section is fixed. In a case like this, dropdown needs to be displayed below the application header but a modal dialog should be displayed above. PrimeNG configuration offers the zIndex property to customize the default values for components categories. Default values are described below and can be customized when setting up PrimeNG.
TypeScript Example ```typescript providePrimeNG({ zIndex: { modal: 1100, // dialog, sidebar overlay: 1000, // dropdown, overlaypanel menu: 1000, // overlay menus tooltip: 1100 // tooltip } }) ```
--- # Styled Mode Choose from a variety of pre-styled themes or develop your own. ## Architecture PrimeNG is a design agnostic library so unlike some other UI libraries it does not enforce a certain styling such as material design. Styling is decoupled from the components using the themes instead. A theme consists of two parts; base and preset . The base is the style rules with CSS variables as placeholders whereas the preset is a set of design tokens to feed a base by mapping the tokens to CSS variables. A base may be configured with different presets, currently Aura, Material, Lara and Nora are the available built-in options. The core of the styled mode architecture is based on a concept named design token , a preset defines the token configuration in 3 tiers; primitive , semantic and component . Primitive Tokens Primitive tokens have no context, a color palette is a good example for a primitive token such as blue-50 to blue-900 . A token named blue-500 may be used as the primary color, the background of a message however on its own, the name of the token does not indicate context. Usually they are utilized by the semantic tokens. Semantic Tokens Semantic tokens define content and their names indicate where they are utilized, a well known example of a semantic token is the primary.color . Semantic tokens map to primitive tokens or other semantic tokens. The colorScheme token group is a special variable to define tokens based on the color scheme active in the application, this allows defining different tokens based on the color scheme like dark mode. Component Tokens Component tokens are isolated tokens per component such as inputtext.background or button.color that map to the semantic tokens. As an example, button.background component token maps to the primary.color semantic token which maps to the green.500 primitive token. Best Practices Use primitive tokens when defining the core color palette and semantic tokens to specify the common design elements such as focus ring, primary colors and surfaces. Components tokens should only be used when customizing a specific component. By defining your own design tokens as a custom preset, you'll be able to define your own style without touching CSS. Overriding the PrimeNG components using style classes is not a best practice and should be the last resort, design tokens are the suggested approach. ## Bootstrap Bootstrap has a reboot utility to reset the CSS of the standard elements. If you are including this utility, you may give it a layer while importing it. ## Colorscheme A token can be defined per color scheme using light and dark properties of the colorScheme property. Each token can have specific values based on the current color scheme. Common Pitfall When customizing an existing preset, your token overrides may be ignored if you don't properly account for color scheme variations. If the original preset defines a token using the colorScheme property, but your customization only provides a direct value, your override will be ignored because the colorScheme property takes precedence over direct values and the system will continue using the preset's scheme-specific values. When customizing tokens that are not defined with colorScheme in the original preset, your customizations will be applied successfully regardless of how you structure them; whether direct or under colorScheme. Best Practices Check how tokens are defined in the preset before customizing from the source . Always maintain the same structure (direct value or colorScheme) as the original preset. Consider both light and dark mode values when overriding scheme-dependent tokens. This approach ensures your customizations will be applied correctly regardless of the user's selected color scheme. ## Colors Color palette of a preset is defined by the primitive design token group. You can access colors using CSS variables or the $dt utility. @for (color of colors; track color) { {{ color }} @for (shade of shades; track shade) { {{ shade }} } } ## Component The design tokens of a specific component is defined at components layer. Overriding components tokens is not the recommended approach if you are building your own style, building your own preset should be preferred instead. This configuration is global and applies to all card components, in case you need to customize a particular component on a page locally, view the Scoped CSS section for an example. ## Darkmode PrimeNG uses the system as the default darkModeSelector in theme configuration. If you have a dark mode switch in your application, set the darkModeSelector to the selector you utilize such as .my-app-dark so that PrimeNG can fit in seamlessly with your color scheme. Following is a very basic example implementation of a dark mode switch, you may extend it further by involving prefers-color-scheme to retrieve it from the system initially and use localStorage to make it stateful. See this article for more information. In case you prefer to use dark mode all the time, apply the darkModeSelector initially and never change it. It is also possible to disable dark mode completely using false or none as the value of the selector. ## Definepreset The definePreset utility is used to customize an existing preset during the PrimeNG setup. The first parameter is the preset to customize and the second is the design tokens to override. ## Dt The $dt function returns the information about a token like the full path and value. This would be useful if you need to access tokens programmatically. ## Extend The theming system can be extended by adding custom design tokens and additional styles. This feature provides a high degree of customization, allowing you to adjust styles according to your needs, as you are not limited to the default tokens. The example preset configuration adds a new accent button with custom button.accent.color and button.accent.inverse.color tokens. It is also possible to add tokens globally to share them within the components. ## Focusring Focus ring defines the outline width, style, color and offset. Let's use a thicker ring with the primary color for the outline. ## Font There is no design for fonts as UI components inherit their font settings from the application. ## Forms The design tokens of the form input components are derived from the form.field token group. This customization example changes border color to primary on hover. Any component that depends on this semantic token such as dropdown.hover.border.color and textarea.hover.border.color would receive the change. ## Libraries Example layer configuration for the popular CSS libraries. ## Noir The noir mode is the nickname of a variant that uses surface tones as the primary and requires and additional colorScheme configuration to implement. A sample preset configuration with black and white variants as the primary color; ## Options The options property defines the how the CSS would be generated from the design tokens of the preset. prefix The prefix of the CSS variables, defaults to p . For instance, the primary.color design token would be var(--p-primary-color) . darkModeSelector The CSS rule to encapsulate the CSS variables of the dark mode, the default is the system to generate {{ '@' }}media (prefers-color-scheme: dark) . If you need to make the dark mode toggleable based on the user selection define a class selector such as .app-dark and toggle this class at the document root. See the dark mode toggle section for an example. cssLayer Defines whether the styles should be defined inside a CSS layer by default or not. A CSS layer would be handy to declare a custom cascade layer for easier customization if necessary. The default is false . ## Palette Returns shades and tints of a given color from 50 to 950 as an array. ## Presets Aura, Material, Lara and Nora are the available built-in options, created to demonstrate the power of the design-agnostic theming. Aura is PrimeTek's own vision, Material follows Google Material Design v2, Lara is based on Bootstrap and Nora is inspired by enterprise applications. Visit the source code to learn more about the structure of presets. You may use them out of the box with modifications or utilize them as reference in case you need to build your own presets from scratch. ## Primary The primary defines the main color palette, default value maps to the emerald primitive token. Let's setup to use indigo instead. ## Reset In case PrimeNG components have visual issues in your application, a Reset CSS may be the culprit. CSS layers would be an efficient solution that involves enabling the PrimeNG layer, wrapping the Reset CSS in another layer and defining the layer order. This way, your Reset CSS does not get in the way of PrimeNG components. ## Scale PrimeNG UI component use rem units, 1rem equals to the font size of the html element which is 16px by default. Use the root font-size to adjust the size of the components globally. This website uses 14px as the base so it may differ from your application if your base font size is different. ## Scopedtokens Design tokens can be scoped to a certain component using the dt property. In this example, first switch uses the global tokens whereas second one overrides the global with its own tokens. This approach is recommended over the ::ng-deep as it offers a cleaner API while avoiding the hassle of CSS rule overrides. ## Specificity The @layer is a standard CSS feature to define cascade layers for a customizable order of precedence. If you need to become more familiar with layers, visit the documentation at MDN to begin with. The cssLayer is disabled by default, when it is enabled at theme configuration, PrimeNG wraps the built-in style classes under the primeng cascade layer to make the library styles easy to override. CSS in your app without a layer has the highest CSS specificity, so you'll be able to override styles regardless of the location or how strong a class is written. ## Surface The color scheme palette that varies between light and dark modes is specified with the surface tokens. Example below uses zinc for light mode and slategray for dark mode. With this setting, light mode, would have a grayscale tone and dark mode would include bluish tone. ## Tailwind Tailwind CSS includes a reset utility in base called preflight . If you are using this feature, wrap the base and utilities in separate layers and make sure primeng layer comes after the base. ## Theme The theme property is used to customize the initial theme.
TypeScript Example ```typescript import { ApplicationConfig } from '@angular/core'; import { providePrimeNG } from 'primeng/config'; import Aura from '@primeuix/themes/aura'; export const appConfig: ApplicationConfig = { providers: [ providePrimeNG({ theme: { preset: Aura } }) ] }; ```
## Updatepreset Merges the provided tokens to the current preset, an example would be changing the primary color palette dynamically. ## Updateprimarypalette Updates the primary colors, this is a shorthand to do the same update using updatePreset . ## Updatesurfacepalette Updates the surface colors, this is a shorthand to do the same update using updatePreset . ## Usepreset Replaces the current presets entirely, common use case is changing the preset dynamically at runtime. --- # Unstyled Mode Theming PrimeNG with alternative styling approaches. ## Architecture The term unstyled is used to define an alternative styling approach instead of the default theming with design tokens. In unstyled mode the css variables of the design tokens and the css rule sets that utilize them are not included. Here is an example of an Unstyled Select, the core functionality and accessibility is provided whereas styling is not included. ## Example Unstyled components require styling using your preferred approach. We recommend using Tailwind CSS with PassThrough attributes, a combination that works seamlessly together. The tailwindcss-primeui even provides special variants such as p-outlined: , p-vertical for the PrimeNG components. The example below demonstrates how to style a button component with Tailwind CSS using PassThrough attributes. Before you begin, refer to the pass through section in the button documentation to familiarize yourself with the component's internal structure and PassThrough attributes. In this example, we'll target the root , label and icon elements to apply custom styles. ```html ``` ## Global A global configuration can be created at application level to avoid repetition via the global pt option so that the styles can be shared from a single location. A particular component can still override a global configuration with its own pt property.
TypeScript Example ```typescript import { ApplicationConfig } from '@angular/core'; export const appConfig: ApplicationConfig = { providers: [ providePrimeNG({ unstyled: true, pt: { button: { root: 'bg-teal-500 hover:bg-teal-700 active:bg-teal-900 cursor-pointer py-2 px-4 rounded-full border-0 flex gap-2', label: 'text-white font-bold text-lg', icon: 'text-white !text-xl' } } }) ] }; ```
## Setup Unstyled mode is enabled for the whole suite by enabling unstyled option during PrimeNG installation. Alternatively even in the default styled mode, a particular component can still be used as unstyled by adding the unstyled prop of the component. ## Voltui Tailwind CSS is perfect fit for the unstyled mode, PrimeTek has even initiated a new UI library called Volt UI based on the unstyled PrimeVue and Tailwind CSS v4. Volt follows the code ownership model where the components are located in the application codebase rather than node_modules. All components within Volt are essentially wrapped versions of the unstyled equivalents, with an added layer of theming through Tailwind CSS v4. This approach, along with the templating features, offers complete control over the theming and presentation. Volt will also be available for PrimeReact. In the future, PrimeTek may bring Volt to Angular via PrimeNG if there is significant community demand. Currently, Volt-Vue can serve as a reference when styling your unstyled PrimeNG components with Tailwind CSS. --- # Icons PrimeIcons is the default icon library of PrimeNG with over 250 open source icons. ## Basic PrimeIcons use the pi pi-{icon} syntax such as pi pi-check . A standalone icon can be displayed using an element such as i or span ```html ``` ## Color Icon color is defined with the color property which is inherited from parent by default. ```html ``` ## Constants Constants API is available to reference icons easily when used programmatically.
TypeScript Example ```typescript import { Component } from '@angular/core'; import { PrimeIcons, MenuItem } from 'primeng/api'; @Component({ selector: 'prime-icons-constants-demo', templateUrl: './prime-icons-constants-demo.html' }) export class PrimeIconsConstantsDemo { items: MenuItem[]; ngOnInit() { this.items = [ { label: 'New', icon: PrimeIcons.PLUS, }, { label: 'Delete', icon: PrimeIcons.TRASH } ]; } } ```
## Download PrimeIcons is available at npm, run the following command to download it to your project. ## Figma PrimeIcons library is now available on Figma Community . By adding them as a library, you can easily use these icons in your designs. ## Import CSS file of the icon library needs to be imported in styles.scss of your application. ## List Here is the full list of PrimeIcons. More icons will be added periodically and you may also request new icons at the issue tracker. ## Size Size of an icon is controlled with the font-size property of the element. ```html ``` ## Spin Special pi-spin class applies infinite rotation to an icon. ```html ``` --- # Custom Icons Use custom icons with PrimeNG components. ## Fontawesome Font Awesome is a popular icon library with a wide range of icons. ```html ``` ## Image Any type of image can be used as an icon. ```html dropdown icon ``` ## Material Material icons is the official icon library based on Google Material Design. ```html arrow_drop_down ``` ## Svg Inline SVGs are embedded inside the dom. ```html ``` --- # Pass Through Pass Through Props allow direct access to the underlying elements for complete customization. ## Basic Each component has a special pt property to define an object with keys corresponding to the available DOM elements. Each value can either be a string, an object or a function that returns a string or an object to define the arbitrary properties to apply to the element such as styling, aria, data-* or custom attributes. If the value is a string or a function that returns a string, it is considered as a class definition and added to the class attribute of the element. Every component documentation has a dedicated section to document the available section names exposed via PT. ```html

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { PanelModule } from 'primeng/panel'; @Component({ selector: 'panel-pt-demo', templateUrl: './panel-pt-demo.html', standalone: true, imports: [PanelModule] }) export class PanelPtDemo { pt = { root: '!border !border-primary !rounded-xl p-4', header: (options) => ({ id: 'myPanelHeader', style: { 'user-select': 'none' }, class: ['!text-primary font-bold !p-0'] }), content: { class: 'text-primary-700 dark:text-primary-200 !p-0 mt-2' }, title: 'text-xl', pcToggleButton: { icon: { class: 'text-primary' } } }; } ```
## Global PassThrough object can also be defined at a global level to apply all components in an application using the providePrimeNG provider. For example, with the configuration here all panel headers have the bg-primary style class and all autocomplete components have a fixed width. These settings can be overridden by a particular component as components pt property has higher precedence over global pt by default.
TypeScript Example ```typescript import { ApplicationConfig } from '@angular/core'; import { providePrimeNG } from 'primeng/config'; export const appConfig: ApplicationConfig = { providers: [ providePrimeNG({ pt: { panel: { header: { class: 'bg-primary text-primary-contrast' } }, autocomplete: { pcInputText: { root: 'w-64' // OR { class: 'w-64' } } } } }) ] }; ```
## Instance In cases where you need to access the UI Component instance, define a component passthrough type that exposes the component instance or a function that receives a PassThroughContext as parameter.
TypeScript Example ```typescript import { Component } from '@angular/core'; import { PassThroughContext } from 'primeng/api'; import { Panel, PanelModule, PanelPassThrough } from 'primeng/panel'; @Component({ selector: 'panel-pt-demo', template: \` Content \`, standalone: true, imports: [PanelModule] }) export class PanelPtDemo { pt: PanelPassThrough = { header: (context: PassThroughContext) => { const instance = context.instance; const element = instance.el; return { id: 'myPanelHeader', 'data-custom': 'prime', style: { userSelect: 'none' }, class: [{ 'overflow-hidden': instance.toggleable }, '!text-white font-bold !p-0 !bg-transparent !border-none'] }; } }; } ```
## Introduction In traditional 3rd party UI libraries, users are limited to the API provided by component author. This API commonly consists of inputs, outputs, and content projection. Whenever a requirement emerges for a new customization option in the API, the component author needs to develop and publish it with a new release. Vision of PrimeTek is "Your Components, Not Ours" . The pass through feature is a key element to implement this vision by exposing the component internals in order to apply arbitrary attributes and listeners to the DOM elements. The primary advantage of this approach is that it frees you from being restricted by the main component API. We recommend considering the pass-through feature whenever you need to tailor a component that lacks a built-in feature for your specific requirement. Each component has a special pt property to define an object with keys corresponding to the available DOM elements. A value of a key can either be a string, an object or a function to define the arbitrary properties such as styling, aria, data-* or custom attributes for the element. If the value is a string or a function that returns a string, it serves as a shorthand for a style class definition. Every component documentation has a dedicated segment to document the available section names in the interactive PT Viewer. Panel Example In this example, a Panel is customized with various options through pt . The styling is overriden with Tailwind CSS and header receives custom attributes along with a click event. The attributes passed to the header are not available in the component API, thanks to PassThrough feature, this is no longer an issue as you are not limited to the component api. Note that, you may avoid the ! based overrides in Tailwind classes if you setup CSS Layers with PrimeNG. Visit the Override section at Tailwind integration for examples.
TypeScript Example ```typescript import { Component } from '@angular/core'; import { Panel, PanelModule, PanelPassThrough } from 'primeng/panel'; @Component({ selector: 'panel-pt-demo', templateUrl: \` ... \`, standalone: true, imports: [PanelModule] }) export class PanelPtDemo { pt: PanelPassThrough = { root: '!border !border-transparent !rounded-2xl !p-4 !bg-gradient-to-br !from-indigo-600 !to-indigo-400', header: { id: 'myPanelHeader', 'data-custom': 'prime', style: { userSelect: 'none' }, class: ['!text-white font-bold !p-0 !bg-transparent !border-none'], onclick: () => { console.log('Header Clicked'); } }, content: { class: '!text-white dark:text-primary-200 !p-0 mt-2 !font-medium' }, title: 'text-xl' }; } ```
## Lifecycle Lifecycle hooks of components are exposed as pass through using the hooks property so that callback functions can be registered. Available callbacks are onBeforeInit , onInit , onChanges , onDoCheck , onAfterContentInit , onAfterContentChecked , onAfterViewInit , onAfterViewChecked and onDestroy . Refer to the Angular documentation for detailed information about lifecycle hooks.
TypeScript Example ```typescript import { Component } from '@angular/core'; import { Panel, PanelModule, PanelPassThrough } from 'primeng/panel'; @Component({ template: \` Content \`, standalone: true, imports: [PanelModule] }) export class PanelPtDemo { pt: PanelPassThrough = { hooks: { onInit: () => { //panel ngOnInit }, onDestroy: () => { //panel ngOnDestroy } } }; } ```
## Pcprefix A UI component may also use other UI components, in this case section names are prefixed with pc (Prime Component) to denote the PrimeNG component begin used. This distinguishes components from standard DOM elements and indicating the necessity for a nested structure. For example, the badge section is identified as pcBadge because the button component incorporates the badge component internally. ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'pc-prefix-demo', templateUrl: './pc-prefix-demo.html', standalone: true, imports: [ButtonModule] }) export class PcPrefixDemo {} ```
## Ptoptions The ⁠ptOptions property determines how a component's local PassThrough configuration merges with the global PT configuration, as demonstrated in the following examples using both global and component-level settings. The mergeSections defines whether the sections from the main configuration gets added and the mergeProps controls whether to override or merge the defined props. Defaults are true for mergeSections and false for mergeProps . Global Configuration mergeSections: true, mergeProps: false (default) mergeSections: true, mergeProps: true mergeSections: false, mergeProps: true mergeSections: false, mergeProps: false --- # Tailwind CSS Integration between PrimeNG and Tailwind CSS. ## Animations The plugin also adds extended animation utilities that can be used with the styleclass and animateonscroll directives. ```html
``` ## Colorpalette PrimeNG color palette as utility classes. ## Darkmode In styled mode, PrimeNG uses the system as the default darkModeSelector in theme configuration. If you have a dark mode switch in your application, ensure that darkModeSelector is aligned with the Tailwind dark variant for seamless integration. Note that, this particular configuration isn't required if you're utilizing the default system color scheme. Suppose that, the darkModeSelector is set as my-app-dark in PrimeNG. Tailwind v4 Add a custom variant for dark with a custom selector. Tailwind v3 Use the plugins option in your Tailwind config file to configure the plugin. ## Extensions The plugin extends the default configuration with a new set of utilities whose values are derived from the PrimeNG theme in use. All variants and breakpoints are supported e.g. dark:sm:hover:bg-primary . Color Palette Class Property primary-[50-950] Primary color palette. surface-[0-950] Surface color palette. primary Default primary color. primary-contrast Default primary contrast color. primary-emphasis Default primary emphasis color. border-surface Content border color. bg-emphasis Emphasis background e.g. hovered element. bg-highlight Highlight background. bg-highlight-emphasis Highlight background with emphasis. rounded-border Border radius. text-color Text color with emphasis. text-color-emphasis Default primary emphasis color. text-muted-color Secondary text color. text-muted-color-emphasis Secondary text color with emphasis. ## Form Using Tailwind utilities for the responsive layout of a form with PrimeNG components. ```html
{{ selectedCountry.name }}
{{ country.name }}
``` ## Headless A headless PrimeNG dialog with a custom UI. ```html
``` ## Override Tailwind utilities may not be able to override the default styling of components due to css specificity, there are two possible solutions; Import and CSS Layer. Important Use the ! as a prefix to enforce the styling. This is not the recommend approach, and should be used as last resort to avoid adding unnecessary style classes to your bundle. Tailwind v4 Tailwind v3 CSS Layer CSS Layer provides control over the css specificity so that Tailwind utilities can safely override components. Tailwind v4 Ensure primeng layer is after theme and base , but before the other Tailwind layers such as utilities . No change in the CSS configuration is required. Tailwind v3 The primeng layer should be between base and utilities. Tailwind v3 does not use native layer so needs to be defined with CSS. ## Overview Tailwind CSS is a popular CSS framework based on a utility-first design. The core provides flexible CSS classes with predefined CSS rules to build your own UI elements. For example, instead of an opinionated btn class as in Bootstrap, Tailwind offers primitive classes like bg-blue-500 , rounded and p-4 to apply a button. Tailwind is an outstanding CSS library, however it lacks a true comprehensive UI suite when combined with Angular, this is where PrimeNG comes in by providing a wide range of highly accessible and feature rich UI component library. The core of PrimeNG does not depend on Tailwind CSS, instead we provide the necessary integration points such as the primeui tailwind plugin. ## Plugin The tailwindcss-primeui is an official plugin by PrimeTek to provide first class integration between a Prime UI library like PrimeNG and Tailwind CSS. It is designed to work both in styled and unstyled modes. In styled mode, for instance the semantic colors such as primary and surfaces are provided as Tailwind utilities e.g. bg-primary , text-surface-500 , text-muted-color . If you haven't already done so, start by integrating Tailwind into your project. Detailed steps for this process can be found in the Tailwind documentation . After successfully installing Tailwind, proceed with the installation of the PrimeUI plugin. This single npm package comes with two libraries: the CSS version is compatible with Tailwind v4, while the JS version is designed for Tailwind v3. Tailwind v4 In the CSS file that contains the tailwindcss import, add the tailwindcss-primeui import as well. For a comprehensive starter guide, review the primeng-quickstart-tailwind repository which demonstrates the integration. Tailwind v3 Use the plugins option in your Tailwind config file to configure the plugin. --- # LLMs.txt LLM-optimized documentation endpoints for PrimeNG components. ## Llmsfulltxt The llms-full.txt file is a complete list of all the pages in the PrimeNG documentation. It is used to help AI models understand the entire documentation set. ## Llmstxt The llms.txt file is an industry standard that helps AI models better understand and navigate the PrimeNG documentation. It lists key pages in a structured format, making it easier for LLMs to retrieve relevant information. ## Markdownextension Add a .md to a page's URL to display a Markdown version of that page. --- # Accessibility PrimeNG has WCAG 2.1 AA level compliance. ## Colors Colors on a web page should aim a contrast ratio of at least 4.5:1 and consider a selection of colors that do not cause vibration. Good Contrast Color contrast between the background and the foreground content should be sufficient enough to ensure readability. Example below displays two cases with good and bad samples. GOOD BAD Vibration Color vibration is leads to an illusion of motion due to choosing colors that have low visibility against each other. Color combinations need to be picked with caution to avoid vibration. VIBRATE Dark Mode Highly saturated colors should be avoided when used within a dark design scheme as they cause eye strain. Instead desaturated colors should be preferred. Indigo 500 Indigo 200 ## Formcontrols Native form elements should be preferred instead of elements that are meant for other purposes like presentation. As an example, button below is rendered as a form control by the browser, can receive focus via tabbing and can be used with space key as well to trigger. On the other hand, a fancy css based button using a div has no keyboard or screen reader support. tabindex is required to make a div element accessible in addition to use a keydown to bring the keyboard support back. To avoid the overload and implementing functionality that is already provided by the browser, native form controls should be preferred. Relations Form components must be related to another element that describes what the form element is used for. This is usually achieved with the label element. ## Introduction According to the World Health Organization, 15% of the world population has a disability to some degree. As a result, accessibility features in any context such as a ramp for wheelchair users or a multimedia with captions are crucial to ensure content can be consumed by anyone. Disabilities Types of disabilities are diverse so you need to know your audience well and how they interact with the content created. There four main categories; Visual Impairments Blindness, low-level vision or color blindness are the common types of visual impairments. Screen magnifiers and the color blind mode are usually built-in features of the browsers whereas for people who rely on screen readers, page developers are required to make sure content is readable by the readers. Popular readers are NVDA , JAWS and ChromeVox . Hearing Impairments Deafness or hearing loss refers to the inability to hear sounds totally or partially. People with hearing impairments use assistive devices however it may not be enough when interacting with a web page. Common implementation is providing textual alternatives, transcripts and captions for content with audio. Mobility Impairments People with mobility impairments have disabilities related to movement due to loss of a limb, paralysis or other varying reasons. Assistive technologies like a head pointer is a device to interact with a screen whereas keyboard or a trackpad remain as solutions for people who are not able to utilize a mouse. Cognitive Impairments Cognitive impairments have a wider range that includes people with learning disabilities, depression and dyslexia. A well designed content also leads to better user experience for people without disabilities so designing for cognitive impairments result in better design for any user. ## Semantichtml HTML offers various element to organize content on a web page that screen readers are aware of. Preferring Semantic HTML for good semantics provide out of the box support for reader which is not possible when regular div elements with classes are used. Consider the following example that do not mean too much for readers. Same layout can be achieved using the semantic elements with screen reader support built-in. ## Waiaria ARIA refers to "Accessible Rich Internet Applications" is a suite to fill the gap where semantic HTML is inadequate. These cases are mainly related to rich UI components/widgets. Although browser support for rich UI components such as a datepicker or colorpicker has been improved over the past years many web developers still utilize UI components derived from standard HTML elements created by them or by other projects like PrimeNG. These types of components must provide keyboard and screen reader support, the latter case is where the WAI-ARIA is utilized. ARIA consists of roles, properties and attributes. Roles define what the element is mainly used for e.g. checkbox , dialog , tablist whereas States and Properties define the metadata of the element like aria-checked , aria-disabled . Consider the following case of a native checkbox. It has built-in keyboard and screen reader support. A fancy checkbox with css animations might look more appealing but accessibility might be lacking. Checkbox below may display a checked font icon with animations however it is not tabbable, cannot be checked with space key and cannot be read by a reader. One alternative is using ARIA roles for readers and use javascript for keyboard support. Notice the usage of aria-labelledby as a replacement of the label tag with for. However the best practice is combining semantic HTML for accessibility while keeping the design for UX. This approach involves hiding a native checkbox for accessibility and using javascript events to update its state. Notice the usage of p-sr-only that hides the elements from the user but not from the screen reader. A working sample is the PrimeNG checkbox that is tabbable, keyboard accessible and is compliant with a screen reader. Instead of ARIA roles it relies on a hidden native checkbox. Remember Me ## Wcag WCAG refers to Web Content Accessibility Guideline , a standard managed by the WAI (Web Accessibility Initiative) of W3C (World Wide Web Consortium). WCAG consists of recommendations for making the web content more accessible. PrimeNG components aim high level of WCAG compliancy in the near future. Various countries around the globe have governmental policies regarding web accessibility as well. Most well known of these are Section 508 in the US and Web Accessibility Directive of the European Union. --- # Animations Built-in CSS animations for PrimeNG components. ## Anchoredoverlays Anchored overlays are the components that have a floating ui positioned relatively to another element such as Select, Popover. The enter and leave animations are defined with the .p-anchored-overlay-enter-active and .p-anchored-overlay-leave-active classes. ## Collapsibles Collapsible components have a content that is toggleable including Accordion, Panel, Fieldset, Stepper and PanelMenu. The enter and leave animations are defined with the .p-collapsible-enter-active and .p-collapsible-leave-active classes. Header I Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Header II Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. Header III Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi. ## Dialog Overlays such as Dialog and Drawer are positioned relative to the viewport and have their own animations. Update your information. Username Email ## Disable Individual animations can be reduced and even disabled completely using the animation duration. ## Introduction Various PrimeNG Components utilize native CSS animations to provide an enhanced user experience. The default animations are based on the best practices recommended by the usability experts. In case you need to customize the default animations, this documentation covers the entire set of built-in animations. Animations are defined using a combination of style classes and keyframes. The ⁠ .{classname}-enter-active and ⁠ .{classname}-leave-active classes specify the animation name, duration, and easing function. You can customize animations globally by overriding the default animation classes, affecting all components. Alternatively, you can apply scoped classes to individual components to modify their animations independently. For demo purposes, this second approach is used throughout the next sections. ## Reference List of class names of the CSS animations used by the components. Component Enter Class Leave Class Accordion .p-collapsible-enter-active .p-collapsible-leave-active AutoComplete .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active CascadeSelect .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active ColorPicker .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active ConfirmPopup .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active ContextMenu .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active DatePicker .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active Dialog .p-dialog-enter-active .p-dialog-leave-active Drawer .p-drawer-enter-active .p-drawer-leave-active Fieldset .p-collapsible-enter-active .p-collapsible-leave-active Galleria .p-galleria-enter-active .p-galleria-leave-active Image .p-image-original-enter-active .p-image-original-leave-active Menu .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active Message .p-message-enter-active .p-message-leave-active Modal Masks .p-overlay-mask-enter-active .p-overlay-mask-leave-active MultiSelect .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active Panel .p-collapsible-enter-active .p-collapsible-leave-active PanelMenu .p-collapsible-enter-active .p-collapsible-leave-active Password .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active Select .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active Stepper .p-collapsible-enter-active .p-collapsible-leave-active TieredMenu .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active Toast .p-toast-message-enter-active .p-toast-message-leave-active TreeSelect .p-anchored-overlay-enter-active .p-anchored-overlay-leave-active --- # RTL Right-to-left support for PrimeNG components. ## Configuration The PrimeNG components natively support Right-to-Left (RTL) text direction through a modern CSS implementation utilizing FlexBox and classes like *-inline-start and *-block-end . Consequently, no JavaScript configuration is necessary; setting the document's text direction to RTL is sufficient to enable this feature. The RTL setting can either be set using the dir attribute or with the direction style property. ## Limitations RTL is widely supported by the UI suite except the Galleria and Carousel components. These components will be enhanced with a modern implementation in upcoming versions with built-in support for RTL. --- # Migration v19 Migration guide to PrimeNG v19. ## Breakingchanges Configuration The PrimeNGConfig has been replaced by PrimeNG and the initial configuration is now done via the providePrimeNG provider during startup. See the installation section for an example. SASS Themes The styled mode theming has been reimplemented from scratch based on an all-new architecture. The theme.css and the primeng/resources do not exist anymore, so any imports of these assets needs to be removed. If you had a custom theme for v17, the theme needs to be recreated using the new APIs. See the customization section at styled mode for details. Removed Components TriStateCheckbox | Use Checkbox with indeterminate option. DataViewLayoutOptions | Use SelectButton instead. pAnimate | Use pAnimateOnScroll instead. Removed Files Themes under the primeng/resources path, migration to new styled mode is necessary. Messages and Message Messages component is deprecated due to unnecessary role of being just a wrapper around multiple message instances and it's replaced with the new Message . Instead of message, users now need to loop through their custom array to display multiple messages to achieve same behavior. The spacing, closable and life properties of the Message have breaking changes to provide Message functionality. Default margin is removed, closable is false by default and messages do not disappear automatically. Message Interface Message interface in primeng/api is renamed as ToastMessageOptions due to name collision with the Message component. Removed Features Sidebar/Drawer size property is removed, use a responsive class utilty as replacement, demos have new examples. Removed Style Classes .p-link , use a button in link mode. .p-highlight , each component have its own class such as .p-select-option-selected . .p-fluid , use the new built-in fluid property of the supported components or the Fluid component. PrimeFlex CSS In case you are using PrimeFlex CSS library, upgrade to PrimeFlex v4 since PrimeFlex v3 is not compatible with PrimeNG v18+ ## Deprecatedcomponents Deprecated Components Components that are deprecated since their functionality is provided by other components. Chips | Use AutoComplete with multiple enabled and typeahead disabled. TabMenu | Use Tabs without panels. Steps | Use Stepper without panels. InlineMessage | Use Message component. TabView | Use the new Tabs components. Accordion | Use with the new AccordionHeader and AccordionContent components. Messages | Use with the new Message component. pDefer | Use Angular defer instead. ## Migrationoverview At PrimeTek, we have been developing UI component libraries since 2008. The web continues to undergo technological advancements, and as a result, we have to modernize and update our libraries to stay relevant. PrimeNG v18 is the next-generation version that fully embraces modern Web APIs and removes technical debt like the legacy-styled mode. Every component has been reviewed and enhanced. The most notable feature is the new styled mode implementation. Previous iterations use SASS at an external repo called PrimeNG-sass-theme which requires compilation of a theme.css a file. This file had to be included in the application and need to be swapped at runtime for basic tasks like dark mode or primary color changes. In v18, styled mode is now part of the core, SASS is not used at all, and a new design token based architecture that fully utilizes CSS variables has been created. The new API is modern and superior to the legacy styled mode. Names of some of the components have been changed to more common alternatives for example, Popover replaced OverlayPanel and InputSwitch is now called ToggleSwitch . Each component has been reviewed for a consistent naming between CSS class names and sections. An example would be the option element of a Select component that uses p-select-option for the class name. Components have been utilized more within other components, for instance Dialog close button is not actually a PrimeNG button so that closeButtonProps can be used to enable the features of button like outlined, raised and more. ## Renamedcomponents Renamed Components Old names are deprecated but still functional, migrate to new import paths instead e.g. primeng/calendar becomes primeng/datepicker . Calendar -> DatePicker . Dropdown -> Select . InputSwitch -> ToggleSwitch . OverlayPanel -> Popover . Sidebar -> Drawer . --- # Migration v20 Migration guide to PrimeNG v20. ## Backwardcompatible Form Enhancements In this iteration, all form components have been reviewed and new demos for template-driven and reactive forms have been added. During this work, limitations have been identified and resolved as well. In addition, we've introduced a new property named invalid to the form components that you may use style a component as invalid. In previous versions, form components style themselves as invalid using a built-in style like the following. This style is opinionated as it is specifally for invalid and dirty states ignoring other potential UX requirements like touched/untouched or form submit. In v20, the new invalid provides full control to highlight a component a invalid. This styling change is backward compatible, meaning the opinionated ng-invalid.ng-dirty class is still included however in future versions, it will be removed. PrimeUIX Themes PrimeUIX is a shared package between all Prime libraries, this shared approach allows PrimeTek teams to share theming and the Design team who is responsible for the Figma UI Kit to work on a single design file, which is the single source of truth. Prior to v20, PrimeNG has its own fork in default styles and for the design tokens {{ '@' }}primeng/themes package is required. With v20, PrimeNG receives the styles from {{ '@' }}primeuix/styles under the hood and the design tokens as theme presets are loaded from {{ '@' }}primeuix/themes . The components need to be adjusted to fit in the PrimeUIX theming by using the host element where applicable, as a result for the components that use host element (<p-* />) as their main container, the styleClass became obselete since native class attribute is already available on the custom element. Refer to the documentation of a particular component to find out if styleClass is deprecated. All of these changes are backward compatible, {{ '@' }}primeng/themes use {{ '@' }}primeuix/themes internally, and migration is easy as replacing the dependency {{ '@' }}primeng/themes with {{ '@' }}primeuix/themes in your application. ## Breaking Our team has put in great deal of effort while updating PrimeNG, and there are no filed breaking changes in v20. ## Deprecations The following items are marked as deprecated. API Deprecated Since Replacement Removal Status @primeng/themes v20 @primeuix/themes v22 pTemplate v20 ng-template with a template reference variable v22 styleClass *(for host enabled components) v20 class v22 Global inputStyle config v20 inputVariant v22 CamelCase Selectors v20 Kebab case v22 pButton iconPos, loadingIcon, icon and label properties v20 pButtonIcon and pButtonLabel directives v22 pButton buttonProps property v20 Use button properties directly on the element v22 p-button badgeClass property v20 badgeSeverity property v22 AutoComplete minLength property v20 minQueryLength v22 OrganizationChart preserveSpace property v20 Obselete property, had no use v22 Paginator dropdownAppendTo property v20 appendTo v22 Message text and escape properties v20 Content projection v22 Password maxLength property v20 maxlength property v22 TreeSelect containerStyle/containerStyleClass properties v20 style and class v22 Table responsiveLayout property v20 Always defaults to scroll, stack mode needs custom implementation v22 TreeSelect default template v20 value template v22 pBadge directive v20 OverlayBadge component v22 clearFilterIcon template of Table v20 Obsolete, not utilized. v22 Inplace closable property. v20 Use templating with closeCallback . v22 ## Overview PrimeNG v20 is an evolution rather than a revolution compared to v18/v19 that introduced the brand new theming architecture. V20 focuses on form enhancements along with the primeuix migration for shared theming between all Prime projects including PrimeVue, PrimeReact and the upcoming projects such as PrimeUI web components. As of v20, PrimeNG has switched PrimeNG to semantic versioning, and as a result changes are iterative, with a smooth migration strategy and no breaking changes. In the future versions, same approach will be put in action and migrations will be trivial with no breaking changes. ## Removals The list of items that were deprecated in previous releases and removed in this iteration. API Deprecated Since Replacement Status in v20 Calendar v18 DatePicker Dropdown v18 Select InputSwitch v18 ToggleSwitch OverlayPanel v18 Popover Sidebar v18 Drawer Chips v18 AutoComplete in multiple mode without typehead option TabMenu v18 Tabs without panels Steps v18 Stepper without panels Messages v18 Message InlineMessage v18 Message TabView v18 Tabs Accordion activeIndex property v18 value property Accordion headerAriaLevel property v18 AccordionHeader aria-level attribute AccordionTab v18 AccordionPanel, AccordionHeader, AccordionContent AutoComplete field property v18 optionLabel property AutoComplete itemSize property v18 virtualScrollItemSize property pDefer v18 Angular deferred views pAutoFocus autofocus property v18 Default attribute directive {{ '[pAutoFocus]="true|false"' }} Badge size property v18 badgeSize property DatePicker monthNavigator, yearNavigator, yearRange, locale properties v18 Obsolete, not utilized. Dialog positionLeft, responsive, breakpoint properties v18 Obsolete, not utilized. InputMask autoFocus property v18 autofocus property. MultiSelect checkicon template v18 headercheckboxicon and itemcheckboxicon . MultiSelect/Select baseZIndex, autoZIndex, showTransitionOptions, hideTransitionOptions v14 overlayOptions property Rating onCancel event and cancelIcon template v18 Obsolete, not utilized. MultiSelect defaultLabel property v18 placeholder property. MultiSelect/Select itemSize property v18 virtualScrollItemSize property Select autoDisplayFirst property v17 Set initial value by model instead TreeSelect showTransitionOptions, hideTransitionOptions v14 overlayOptions property Panel expandIcon and collapseIcon properties v18 headericons template StyleClass enterClass/leaveClass properties v18 enterFromClass and leaveFromClass properties Table scrollDirection property 14 Obsolete, not utilized. Table responsive property 14 An horizontal scroll is displayed for smaller screens Table/TreeTable virtualRowHeight property v18 virtualScrollItemSize property Table autoLayout property v18 Table always uses autoLayout as implementation requirement Tree virtualNodeHeight property v18 virtualScrollItemSize property --- # Migration v21 Migration guide to PrimeNG v21. ## Breaking Beginning with PrimeNG v20, PrimeTek adopted a no-breaking-change policy for incremental major version updates. PrimeNG v21 maintains this policy with one exception: due to the deprecation of Angular's animations package in Angular v20.2, we have migrated to native CSS-based animations. Consequently, the showTransitionOptions and hideTransitionOptions properties that belong to the animations api are deprecated in v21 and no longer functional. v21 will not cause an error as the properties still exist, however your customizations will be ignored. If you currently use these properties for animation customization, please refer to the new animations documentation for the updated approach. Other than this case, v21 should be a drop-in replacement. If you face with any issues during upgrade, please report an issue using at GitHub. ## Deprecations The following items are marked as deprecated. API Deprecated Since Replacement Removal Status showTransitionOptions v21 Native CSS animatons v22 hideTransitionOptions v21 Native CSS animatons v22 Directive PT attribute names e.g. ptInputText v21 PT suffix at the end e.g. pInputTextPT v22 contextMenuSelectionMode v21 "joint" mode will be removed in favor of the "separate". Applies to Tree, TreeTable and Table. v22 ## Removals This version contains no API removals. For a list of APIs scheduled for removal in v22, refer to the v20 deprecations section. ## Whatsnew PrimeNG v21 represents a major advancement in PrimeTek's product vision. Key highlights of this release include: PassThrough attributes for enhanced customization. Unstyled Mode for complete styling flexibility. Modern CSS-based animations . The deprecated provideAnimationsAsync is safe to remove. Initial zoneless support for improved performance. AI-enhanced documentation for better developer experience. Notes The internal packages @primeuix/styles and @primeuix/themes should be version 2.0.2 or higher. These packages are updated automatically with a fresh install. If you encounter any issues with visuals or animations, please verify that you are using the correct versions of these packages. --- # Components # Angular Accordion Component Accordion groups a collection of contents in tabs. ## Accessibility Screen Reader Accordion header elements have a button role and use aria-controls to define the id of the content section along with aria-expanded for the visibility state. The value to read a header element defaults to the value of the header property and can be customized by defining an aria-label or aria-labelledby property. Each header has a heading role, for which the level is customized by headerAriaLevel and has a default level of 2 as per W3C specifications. Disabled accordions headers use aria-disabled and are excluded from the keybord navigation. The content uses region role, defines an id that matches the aria-controls of the header and aria-labelledby referring to the id of the header. Header Keyboard Support ## Basic Accordion is defined using AccordionPanel , AccordionHeader and AccordionContent components. Each AccordionPanel must contain a unique value property to specify the active item. **Basic Usage:** ```html Header I

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Header II

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.

Header III

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.

``` ## Controlled Panels can be controlled programmatically using value property as a model. **Basic Usage:** ```html
Header I

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Header II

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.

Header III

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.

```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AccordionModule } from 'primeng/accordion'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'accordion-controlled-demo', templateUrl: './accordion-controlled-demo.html', standalone: true, imports: [AccordionModule, ButtonModule] }) export class AccordionControlledDemo { activeIndex: number | undefined = 0; activeIndexChange(index : number){ this.activeIndex = index } } ```
## Disabled Enabling disabled property of an AccordionTab prevents user interaction. **Basic Usage:** ```html Header I

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Header II

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.

Header III

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.

Header IV
```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AccordionModule } from 'primeng/accordion'; @Component({ selector: 'accordion-disabled-demo', templateUrl: './accordion-disabled-demo.html', standalone: true, imports: [AccordionModule] }) export class AccordionDisabledDemo {} ```
## Dynamic AccordionPanel can be generated dynamically using the standard @for block. **Basic Usage:** ```html @for (tab of tabs; track tab.title) { {{ tab.title }}

{{ tab.content }}

}
```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AccordionModule } from 'primeng/accordion'; import { CommonModule } from '@angular/common'; @Component({ selector: 'accordion-dynamic-demo', templateUrl: './accordion-dynamic-demo.html', standalone: true, imports: [AccordionModule, CommonModule] }) export class AccordionDynamicDemo { tabs = [ { title: 'Title 1', content: 'Content 1', value: '0' }, { title: 'Title 2', content: 'Content 2', value: '1' }, { title: 'Title 3', content: 'Content 3', value: '2' }, ]; } ```
## Import
TypeScript Example ```typescript import { AccordionModule } from 'primeng/accordion'; ```
## Multiple Only one tab at a time can be active by default, enabling multiple property changes this behavior to allow multiple tabs. In this case activeIndex needs to be an array. **Basic Usage:** ```html Header I

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Header II

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.

Header III

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.

```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AccordionModule } from 'primeng/accordion'; @Component({ selector: 'accordion-multiple-demo', templateUrl: './accordion-multiple-demo.html', standalone: true, imports: [AccordionModule] }) export class AccordionMultipleDemo {} ```
## styledoc Following is the list of structural style classes, for theming classes visit theming page. ## Template Accordion is customized with toggleicon template. **Basic Usage:** ```html @if (active) { } @else { } Amy Elsner

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

@if (active) { } @else { } Onyama Limba

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.

@if (active) { } @else { } Ioni Bowcher

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.

```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AccordionModule } from 'primeng/accordion'; import { AvatarModule } from 'primeng/avatar'; import { BadgeModule } from 'primeng/badge'; @Component({ selector: 'accordion-template-demo', templateUrl: './accordion-template-demo.html', standalone: true, imports: [AccordionModule, AvatarModule, BadgeModule] }) export class AccordionTemplateDemo {} ```
## Accordion Panel AccordionPanel is a helper component for Accordion component. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | value | ModelSignal | undefined | Value of the active tab. | | disabled | InputSignalWithTransform | false | Disables the tab when enabled. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | ## Accordion Header AccordionHeader is a helper component for Accordion component. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | ### Templates | Name | Type | Description | |------|------|-------------| | toggleicon | TemplateRef | Toggle icon template. | ## Accordion Accordion groups a collection of contents in tabs. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | value | ModelSignal | undefined | Value of the active tab. | | multiple | InputSignalWithTransform | false | When enabled, multiple tabs can be activated at the same time. | | styleClass | string | - | Class of the element. **(Deprecated)** | | expandIcon | string | - | Icon of a collapsed tab. | | collapseIcon | string | - | Icon of an expanded tab. | | selectOnFocus | InputSignalWithTransform | false | When enabled, the focused tab is activated. | | transitionOptions | string | 400ms cubic-bezier(0.86, 0, 0.07, 1) | Transition options of the animation. **(Deprecated)** | | motionOptions | InputSignal | ... | The motion options. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | ### Emits | Name | Parameters | Description | |------|------------|-------------| | onClose | event: AccordionTabCloseEvent | Callback to invoke when an active tab is collapsed by clicking on the header. | | onOpen | event: AccordionTabOpenEvent | Callback to invoke when a tab gets expanded. | ## Pass Through Options | Name | Type | Description | |------|------|-------------| | root | PassThroughOption | Used to pass attributes to the root's DOM element. | | motion | MotionOptions | Used to pass options to the motion component/directive. | ## Theming ### CSS Classes | Class | Description | |-------|-------------| | p-accordion | Class name of the root element | | p-accordioncontent | Class name of the content wrapper | | p-accordioncontent-content | Class name of the content | | p-accordionheader | Class name of the header | | p-accordionheader-toggle-icon | Class name of the toggle icon | | p-accordionpanel | Class name of the panel | ### Design Tokens | Token | CSS Variable | Description | |-------|--------------|-------------| | accordion.transition.duration | --p-accordion-transition-duration | Transition duration of root | | accordion.panel.border.width | --p-accordion-panel-border-width | Border width of panel | | accordion.panel.border.color | --p-accordion-panel-border-color | Border color of panel | | accordion.header.color | --p-accordion-header-color | Color of header | | accordion.header.hover.color | --p-accordion-header-hover-color | Hover color of header | | accordion.header.active.color | --p-accordion-header-active-color | Active color of header | | accordion.header.active.hover.color | --p-accordion-header-active-hover-color | Active hover color of header | | accordion.header.padding | --p-accordion-header-padding | Padding of header | | accordion.header.font.weight | --p-accordion-header-font-weight | Font weight of header | | accordion.header.border.radius | --p-accordion-header-border-radius | Border radius of header | | accordion.header.border.width | --p-accordion-header-border-width | Border width of header | | accordion.header.border.color | --p-accordion-header-border-color | Border color of header | | accordion.header.background | --p-accordion-header-background | Background of header | | accordion.header.hover.background | --p-accordion-header-hover-background | Hover background of header | | accordion.header.active.background | --p-accordion-header-active-background | Active background of header | | accordion.header.active.hover.background | --p-accordion-header-active-hover-background | Active hover background of header | | accordion.header.focus.ring.width | --p-accordion-header-focus-ring-width | Focus ring width of header | | accordion.header.focus.ring.style | --p-accordion-header-focus-ring-style | Focus ring style of header | | accordion.header.focus.ring.color | --p-accordion-header-focus-ring-color | Focus ring color of header | | accordion.header.focus.ring.offset | --p-accordion-header-focus-ring-offset | Focus ring offset of header | | accordion.header.focus.ring.shadow | --p-accordion-header-focus-ring-shadow | Focus ring shadow of header | | accordion.header.toggle.icon.color | --p-accordion-header-toggle-icon-color | Toggle icon color of header | | accordion.header.toggle.icon.hover.color | --p-accordion-header-toggle-icon-hover-color | Toggle icon hover color of header | | accordion.header.toggle.icon.active.color | --p-accordion-header-toggle-icon-active-color | Toggle icon active color of header | | accordion.header.toggle.icon.active.hover.color | --p-accordion-header-toggle-icon-active-hover-color | Toggle icon active hover color of header | | accordion.header.first.top.border.radius | --p-accordion-header-first-top-border-radius | First top border radius of header | | accordion.header.first.border.width | --p-accordion-header-first-border-width | First border width of header | | accordion.header.last.bottom.border.radius | --p-accordion-header-last-bottom-border-radius | Last bottom border radius of header | | accordion.header.last.active.bottom.border.radius | --p-accordion-header-last-active-bottom-border-radius | Last active bottom border radius of header | | accordion.content.border.width | --p-accordion-content-border-width | Border width of content | | accordion.content.border.color | --p-accordion-content-border-color | Border color of content | | accordion.content.background | --p-accordion-content-background | Background of content | | accordion.content.color | --p-accordion-content-color | Color of content | | accordion.content.padding | --p-accordion-content-padding | Padding of content | --- # Angular Animate On Scroll Directive AnimateOnScroll AnimateOnScroll is used to apply animations to elements when entering or leaving the viewport during scrolling. ## Accessibility Screen Reader AnimateOnScroll does not require any roles and attributes. Keyboard Support Component does not include any interactive elements. ## Basic Animation classes are defined with the enterClass and leaveClass properties. This example utilizes tailwindcss-primeui plugin animations however any valid CSS animation is supported. **Basic Usage:** ```html
Scroll Down
Individual Lorem ipsum dolor sit amet consectetur adipisicing elit.
Team Lorem ipsum dolor sit amet consectetur adipisicing elit.
Enterprise Lorem ipsum dolor sit amet consectetur adipisicing elit.
Jenna Thompson Lorem ipsum dolor sit amet consectetur adipisicing elit.
Isabel Garcia Lorem ipsum dolor sit amet consectetur adipisicing elit.
Xavier Mason Lorem ipsum dolor sit amet consectetur adipisicing elit.
850K Customers Lorem ipsum dolor sit amet consectetur adipisicing elit.
$1.5M Revenue Lorem ipsum dolor sit amet consectetur adipisicing elit.
140K Sales Lorem ipsum dolor sit amet consectetur adipisicing elit.
Bandwidth Lorem ipsum dolor sit amet consectetur adipisicing elit.
Storage Lorem ipsum dolor sit amet consectetur adipisicing elit.
Requests Lorem ipsum dolor sit amet consectetur adipisicing elit.
``` ## Import
TypeScript Example ```typescript import { AnimateOnScrollModule } from 'primeng/animateonscroll'; ```
## Animate On Scroll AnimateOnScroll is used to apply animations to elements when entering or leaving the viewport during scrolling. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | enterClass | string | - | Selector to define the CSS class for enter animation. | | leaveClass | string | - | Selector to define the CSS class for leave animation. | | root | HTMLElement | - | Specifies the root option of the IntersectionObserver API. | | rootMargin | string | - | Specifies the rootMargin option of the IntersectionObserver API. | | threshold | number | 0.5 | Specifies the threshold option of the IntersectionObserver API | | once | boolean | false | Whether the scroll event listener should be removed after initial run. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | --- # Angular AutoComplete Component AutoComplete is an input component that provides real-time suggestions when being typed. ## Accessibility Screen Reader Value to describe the component can either be provided via label tag combined with inputId prop or using ariaLabelledBy , ariaLabel props. The input element has combobox role in addition to aria-autocomplete , aria-haspopup and aria-expanded attributes. The relation between the input and the popup is created with aria-controls and aria-activedescendant attribute is used to instruct screen reader which option to read during keyboard navigation within the popup list. In multiple mode, chip list uses listbox role whereas each chip has the option role with aria-label set to the label of the chip. The popup list has an id that refers to the aria-controls attribute of the input element and uses listbox as the role. Each list item has option role and an id to match the aria-activedescendant of the input element. **Basic Usage:** ```html Email ``` ## Advanced This example demonstrates an advanced use case with templating, object handling, dropdown, and multiple mode. **Basic Usage:** ```html
{{ product.name }} {{ product.category }}
\${{ product.price }}
@if (value.price) {
{{ value.name }} \${{ value.price }}
} @else { {{ value }} }
```
TypeScript Example ```typescript import { Component, computed, OnInit, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; import { AutoCompleteModule } from 'primeng/autocomplete'; import { ChipModule } from 'primeng/chip'; import { Product } from '@/domain/product'; import { ProductService } from '@/service/productservice'; @Component({ selector: 'autocomplete-advanced-chips-demo', templateUrl: './autocomplete-advanced-chips-demo.html', standalone: true, imports: [CommonModule, FormsModule, AutoCompleteModule, ChipModule], providers: [ProductService] }) export class AutocompleteAdvancedChipsDemo implements OnInit { products = signal([]); constructor(private productService: ProductService) {} ngOnInit() { this.productService.getProductsSmall().then((data) => this.products.set(data)); } selectedProducts = signal([]); filteredProducts: Product[] = []; filterProducts(event: any) { let filtered: Product[] = []; let query = event.query; for (let i = 0; i < this.products().length; i++) { let product = this.products()[i]; if (product.name?.toLowerCase().indexOf(query.toLowerCase()) == 0) { filtered.push(product); } } this.filteredProducts = filtered; } getProductLabel(product: any): string { if (typeof product === 'string') { return product; } return product?.name || ''; } getProductValue(product: any): any { if (typeof product === 'string') { return { name: product, custom: true }; } return { id: product.id, name: product.name, price: product.price, quantity: product.quantity }; } } ```
## Basic With ⁠multiple enabled, the AutoComplete component behaves like a chips or tags input. Use addOnBlur , ⁠addOnTab , and ⁠separator properties to customize the keystroke behavior for adding items. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoCompleteModule } from 'primeng/autocomplete'; @Component({ selector: 'autocomplete-basic-chips-demo', templateUrl: './autocomplete-basic-chips-demo.html', standalone: true, imports: [FormsModule, AutoCompleteModule] }) export class AutocompleteBasicChipsDemo { valueBlur: any[] = []; valueTab: any[] = []; valueSeparator: any[] = []; valueCombined: any[] = []; } ```
## Basic AutoComplete uses ngModel for two-way binding, requires a list of suggestions and a completeMethod to query for the results. The completeMethod gets the query text as event.query property and should update the suggestions with the search results. **Basic Usage:** ```html ``` ## Clear Icon When showClear is enabled, a clear icon is displayed to clear the value. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoComplete } from 'primeng/autocomplete'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-clear-icon-demo', templateUrl: './autocomplete-clear-icon-demo.html', imports: [AutoComplete, FormsModule], standalone: true, }) export class AutocompleteClearIconDemo { items: any[] = []; value: any; search(event: AutoCompleteCompleteEvent) { this.items = [...Array(10).keys()].map(item => event.query + '-' + item); } } ```
## Disabled When disabled is present, the element cannot be edited and focused. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AutoComplete } from 'primeng/autocomplete'; import { FormsModule } from '@angular/forms'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-disabled-demo', templateUrl: './autocomplete-disabled-demo.html', standalone: true, imports: [FormsModule, AutoComplete] }) export class AutocompleteDisabledDemo { items: any[] | undefined; selectedItem: any; suggestions: any[] | undefined; search(event: AutoCompleteCompleteEvent) { this.suggestions = [...Array(10).keys()].map(item => event.query + '-' + item); } } ```
## Dropdown Enabling dropdown property displays a button next to the input field where click behavior of the button is defined using dropdownMode property that takes blank or current as possible values. blank is the default mode to send a query with an empty string whereas current setting sends a query with the current value of the input. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoCompleteModule } from 'primeng/autocomplete'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-dropdown-demo', templateUrl: './autocomplete-dropdown-demo.html', standalone:true, imports: [FormsModule, AutoCompleteModule] }) export class AutocompleteDropdownDemo { items: any[] | undefined; value: any; search(event: AutoCompleteCompleteEvent) { let _items = [...Array(10).keys()]; this.items = event.query ? [...Array(10).keys()].map((item) => event.query + '-' + item) : _items; } } ```
## Filled Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoComplete } from 'primeng/autocomplete'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-filled-demo', templateUrl: './autocomplete-filled-demo.html', imports: [AutoComplete, FormsModule], standalone: true, }) export class AutocompleteFilledDemo { items: any[] | undefined; selectedItem: any; suggestions: any[] | undefined; search(event: AutoCompleteCompleteEvent) { this.suggestions = [...Array(10).keys()].map(item => event.query + '-' + item); } } ```
## Float Label A floating label appears on top of the input field when focused. Visit FloatLabel documentation for more information. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoComplete } from 'primeng/autocomplete'; import { FloatLabel } from 'primeng/floatlabel'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-float-label-demo', templateUrl: './autocomplete-float-label-demo.html', standalone: true, imports: [FormsModule, AutoComplete, FloatLabel] }) export class AutocompleteFloatLabelDemo { value1: string | undefined; value2: string | undefined; value3: string | undefined; items: any[] | undefined; search(event: AutoCompleteCompleteEvent) { this.items = [...Array(10).keys()].map((item) => event.query + '-' + item); } } ```
## Fluid The fluid prop makes the component take up the full width of its container when set to true. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoComplete } from 'primeng/autocomplete'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-fluid-demo', templateUrl: './autocomplete-fluid-demo.html', imports: [AutoComplete, FormsModule], standalone: true, }) export class AutocompleteFluidDemo { items: any[] = []; value: any; search(event: AutoCompleteCompleteEvent) { this.items = [...Array(10).keys()].map(item => event.query + '-' + item); } } ```
## Force Selection ForceSelection mode validates the manual input to check whether it also exists in the suggestions list, if not the input value is cleared to make sure the value passed to the model is always one of the suggestions. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component, OnInit } from '@angular/core'; import { CountryService } from '@/service/countryservice'; import { AutoComplete } from 'primeng/autocomplete'; import { FormsModule } from '@angular/forms'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-force-selection-demo', templateUrl: './autocomplete-force-selection-demo.html', standalone: true, imports: [FormsModule, AutoComplete], providers: [CountryService] }) export class AutocompleteForceSelectionDemo implements OnInit { countries: any[] | undefined; selectedCountry: any; filteredCountries: any[] | undefined; constructor(private countryService: CountryService) {} ngOnInit() { this.countryService.getCountries().then((countries) => { this.countries = countries; }); } filterCountry(event: AutoCompleteCompleteEvent) { let filtered: any[] = []; let query = event.query; for (let i = 0; i < (this.countries as any[]).length; i++) { let country = (this.countries as any[])[i]; if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) { filtered.push(country); } } this.filteredCountries = filtered; } } ```
**Sample Data:** ```json //CountryService { "name": "Afghanistan", "code": "AF" } ... ``` ## Group Option grouping is enabled when group property is set to true . group template is available to customize the option groups. All templates get the option instance as the default local template variable. **Basic Usage:** ```html
{{ group.label }}
```
TypeScript Example ```typescript import { Component, OnInit } from '@angular/core'; import { FilterService, SelectItemGroup } from 'primeng/api'; import { AutoComplete } from 'primeng/autocomplete'; import { FormsModule } from '@angular/forms'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-grouped-demo', templateUrl: './autocomplete-grouped-demo.html', standalone: true, imports: [AutoComplete, FormsModule], }) export class AutocompleteGroupedDemo implements OnInit { selectedCity: any; filteredGroups: any[] | undefined; groupedCities: SelectItemGroup[] | undefined; constructor(private filterService: FilterService) { } ngOnInit() { this.groupedCities = [ { label: 'Germany', value: 'de', items: [ { label: 'Berlin', value: 'Berlin' }, { label: 'Frankfurt', value: 'Frankfurt' }, { label: 'Hamburg', value: 'Hamburg' }, { label: 'Munich', value: 'Munich' } ] }, { label: 'USA', value: 'us', items: [ { label: 'Chicago', value: 'Chicago' }, { label: 'Los Angeles', value: 'Los Angeles' }, { label: 'New York', value: 'New York' }, { label: 'San Francisco', value: 'San Francisco' } ] }, { label: 'Japan', value: 'jp', items: [ { label: 'Kyoto', value: 'Kyoto' }, { label: 'Osaka', value: 'Osaka' }, { label: 'Tokyo', value: 'Tokyo' }, { label: 'Yokohama', value: 'Yokohama' } ] } ]; } filterGroupedCity(event: AutoCompleteCompleteEvent) { let query = event.query; let filteredGroups = []; for (let optgroup of this.groupedCities) { let filteredSubOptions = this.filterService.filter(optgroup.items, ['label'], query, "contains"); if (filteredSubOptions && filteredSubOptions.length) { filteredGroups.push({ label: optgroup.label, value: optgroup.value, items: filteredSubOptions }); } } this.filteredGroups = filteredGroups; } } ```
## Ifta Label IftaLabel is used to create infield top aligned labels. Visit IftaLabel documentation for more information. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoCompleteModule } from 'primeng/autocomplete'; import { IftaLabelModule } from 'primeng/iftalabel'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-ifta-label-demo', templateUrl: './autocomplete-ifta-label-demo.html', standalone: true, imports: [FormsModule, AutoCompleteModule, IftaLabelModule] }) export class AutocompleteIftaLabelDemo { items: any[] | undefined; value: any; search(event: AutoCompleteCompleteEvent) { this.items = [...Array(10).keys()].map((item) => event.query + '-' + item); } } ```
## Import
TypeScript Example ```typescript import { AutoCompleteModule } from 'primeng/autocomplete'; ```
## Invalid The invalid state is applied using the ⁠invalid property to indicate failed validation, which can be integrated with Angular Forms. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoComplete } from 'primeng/autocomplete'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-invalid-demo', templateUrl: './autocomplete-invalid-demo.html', standalone: true, imports: [FormsModule, AutoComplete] }) export class AutocompleteInvalidDemo { value1: any; value2: any; suggestions: any[] | undefined; search(event: AutoCompleteCompleteEvent) { this.suggestions = [...Array(10).keys()].map((item) => event.query + '-' + item); } } ```
## Multiple Enable multiple selection mode using the ⁠multiple property to allow users to select more than one value from the autocomplete. When enabled, the value reference must be an array. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoComplete } from 'primeng/autocomplete'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-multiple-demo', templateUrl: './autocomplete-multiple-demo.html', standalone: true, imports: [FormsModule, AutoComplete] }) export class AutocompleteMultipleDemo { value1: any[] | undefined; value2: any[] | undefined; items: any[] | undefined; search(event: AutoCompleteCompleteEvent) { this.items = [...Array(10).keys()].map((item) => event.query + '-' + item); } } ```
## Objects AutoComplete can also work with objects using the optionLabel property that defines the label to display as a suggestion. The value passed to the model would still be the object instance of a suggestion. Here is an example with a Country object that has name and code fields such as {name: "United States", code:"USA"} . **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component, OnInit } from '@angular/core'; import { CountryService } from '@/service/countryservice'; import { AutoComplete } from 'primeng/autocomplete'; import { FormsModule } from '@angular/forms'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-objects-demo', templateUrl: './autocomplete-objects-demo.html', standalone: true, imports: [AutoComplete, FormsModule], providers: [CountryService] }) export class AutocompleteObjectsDemo implements OnInit { countries: any[] | undefined; selectedCountry: any; filteredCountries: any[] | undefined; constructor(private countryService: CountryService) {} ngOnInit() { this.countryService.getCountries().then((countries) => { this.countries = countries; }); } filterCountry(event: AutoCompleteCompleteEvent) { let filtered: any[] = []; let query = event.query; for (let i = 0; i < (this.countries as any[]).length; i++) { let country = (this.countries as any[])[i]; if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) { filtered.push(country); } } this.filteredCountries = filtered; } } ```
**Sample Data:** ```json //CountryService { "name": "Afghanistan", "code": "AF" } ... ``` ## reactiveformsdoc AutoComplete can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control. **Basic Usage:** ```html
@if (isInvalid('value')) { Value is required. }
```
TypeScript Example ```typescript import { Component, inject } from '@angular/core'; import { FormBuilder, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms'; import { AutoCompleteModule } from 'primeng/autocomplete'; import { MessageModule } from 'primeng/message'; import { ToastModule } from 'primeng/toast'; import { MessageService } from 'primeng/api'; import { ButtonModule } from 'primeng/button'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-reactive-forms-demo', templateUrl: './autocomplete-reactive-forms-demo.html', standalone: true, imports: [ReactiveFormsModule, AutoCompleteModule, MessageModule, ToastModule, ButtonModule], }) export class AutocompleteReactiveFormsDemo { messageService = inject(MessageService); items: any[] | undefined; exampleForm: FormGroup | undefined; formSubmitted: boolean = false; constructor(private fb: FormBuilder) { this.exampleForm = this.fb.group({ value: ['', Validators.required] }); } search(event: AutoCompleteCompleteEvent) { this.items = [...Array(10).keys()].map((item) => event.query + '-' + item); } onSubmit() { this.formSubmitted = true; if (this.exampleForm.valid) { this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form is submitted', life: 3000 }); this.exampleForm.reset(); this.formSubmitted = false; } } isInvalid(controlName: string) { const control = this.exampleForm.get(controlName); return control?.invalid && (control.touched || this.formSubmitted); } } ```
## Sizes AutoComplete provides small and large sizes as alternatives to the base. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; @Component({ selector: 'autocomplete-size-demo', templateUrl: './autocomplete-size-demo.html', imports: [AutoComplete, FormsModule], standalone: true, }) export class AutocompleteSizesDemo { items: any[] | undefined; value1: any; value2: any; value3: any; search() { this.items = []; } } ```
## styledoc Following is the list of structural style classes, for theming classes visit theming page. ## Template AutoComplete offers multiple templates for customization through templating. **Basic Usage:** ```html
{{ country.name }}
Available Countries
```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { SelectItemGroup } from 'primeng/api'; import { CountryService } from '@/service/countryservice'; import { AutoCompleteModule } from 'primeng/autocomplete'; import { FormsModule } from '@angular/forms'; import { ButtonModule } from 'primeng/button'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-template-demo', templateUrl: './autocomplete-template-demo.html', standalone: true, imports: [FormsModule, AutoCompleteModule, ButtonModule], providers: [CountryService] }) export class AutocompleteTemplateDemo { countries: any[] | undefined; selectedCountryAdvanced: any[] | undefined; filteredCountries: any[] | undefined; constructor(private countryService: CountryService) {} ngOnInit() { this.countryService.getCountries().then((countries) => { this.countries = countries; }); } filterCountry(event: AutoCompleteCompleteEvent) { let filtered: any[] = []; let query = event.query; for (let i = 0; i < (this.countries as any[]).length; i++) { let country = (this.countries as any[])[i]; if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) { filtered.push(country); } } this.filteredCountries = filtered; } } ```
**Sample Data:** ```json //CountryService { "name": "Afghanistan", "code": "AF" } ... ``` ## templatedrivenformsdoc **Basic Usage:** ```html
@if (val.invalid && (val.touched || exampleForm.submitted)) { Value is required. }
```
TypeScript Example ```typescript import { Component, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AutoCompleteModule } from 'primeng/autocomplete'; import { MessageModule } from 'primeng/message'; import { ToastModule } from 'primeng/toast'; import { MessageService } from 'primeng/api'; import { AutoCompleteCompleteEvent } from 'primeng/autocomplete'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'autocomplete-template-driven-forms-demo', templateUrl: './autocomplete-template-driven-forms-demo.html', standalone: true, imports: [FormsModule, AutoCompleteModule, MessageModule, ToastModule, ButtonModule] }) export class TemplateDrivenFormsDemo { messageService = inject(MessageService); items: any[] = []; value: any; search(event: AutoCompleteCompleteEvent) { this.items = [...Array(10).keys()].map((item) => event.query + '-' + item); } onSubmit(form: any) { if (form.valid) { this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form Submitted', life: 3000 }); form.resetForm(); } } } ```
## Virtual Scroll Virtual scrolling is an efficient way of rendering the options by displaying a small subset of data in the viewport at any time. When dealing with huge number of options, it is suggested to enable virtual scrolling to avoid performance issues. Usage is simple as setting virtualScroll property to true and defining virtualScrollItemSize to specify the height of an item. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AutoComplete } from 'primeng/autocomplete'; import { FormsModule } from '@angular/forms'; interface AutoCompleteCompleteEvent { originalEvent: Event; query: string; } @Component({ selector: 'autocomplete-virtual-scroll-demo', templateUrl: './autocomplete-virtual-scroll-demo.html', standalone: true, imports: [FormsModule, AutoComplete] }) export class AutocompleteVirtualScrollDemo { selectedItem: any; filteredItems: any[] | undefined; items: any[] | undefined; filterItems(event: AutoCompleteCompleteEvent) { //in a real application, make a request to a remote url with the query and return filtered results, for demo we filter at client side let filtered: any[] = []; let query = event.query; for (let i = 0; i < (this.items as any[]).length; i++) { let item = (this.items as any[])[i]; if (item.label.toLowerCase().indexOf(query.toLowerCase()) == 0) { filtered.push(item); } } this.filteredItems = filtered; } ngOnInit() { this.items = []; for (let i = 0; i < 10000; i++) { this.items.push({ label: 'Item ' + i, value: 'Item ' + i }); } } } ```
## Auto Complete AutoComplete is an input component that provides real-time suggestions when being typed. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | minLength | number | 1 | Minimum number of characters to initiate a search. **(Deprecated)** | | minQueryLength | number | - | Minimum number of characters to initiate a search. | | delay | number | 300 | Delay between keystrokes to wait before sending a query. | | panelStyle | { [klass: string]: any } | - | Inline style of the overlay panel element. | | styleClass | string | - | Style class of the component. **(Deprecated)** | | panelStyleClass | string | - | Style class of the overlay panel element. | | inputStyle | { [klass: string]: any } | - | Inline style of the input field. | | inputId | string | - | Identifier of the focus input to match a label defined for the component. | | inputStyleClass | string | - | Inline style of the input field. | | placeholder | string | - | Hint text for the input field. | | readonly | boolean | false | When present, it specifies that the input cannot be typed. | | scrollHeight | string | 200px | Maximum height of the suggestions panel. | | lazy | boolean | false | Defines if data is loaded and interacted with in lazy manner. | | virtualScroll | boolean | false | Whether the data should be loaded on demand during scroll. | | virtualScrollItemSize | number | - | Height of an item in the list for VirtualScrolling. | | virtualScrollOptions | ScrollerOptions | - | Whether to use the scroller feature. The properties of scroller component can be used like an object in it. | | autoHighlight | boolean | false | When enabled, highlights the first item in the list by default. | | forceSelection | boolean | false | When present, autocomplete clears the manual input if it does not match of the suggestions to force only accepting values from the suggestions. | | type | string | text | Type of the input, defaults to "text". | | autoZIndex | boolean | true | Whether to automatically manage layering. | | baseZIndex | number | 0 | Base zIndex value to use in layering. | | ariaLabel | string | - | Defines a string that labels the input for accessibility. | | dropdownAriaLabel | string | - | Defines a string that labels the dropdown button for accessibility. | | ariaLabelledBy | string | - | Specifies one or more IDs in the DOM that labels the input field. | | dropdownIcon | string | - | Icon class of the dropdown icon. | | unique | boolean | true | Ensures uniqueness of selected items on multiple mode. | | group | boolean | false | Whether to display options as grouped when nested options are provided. | | completeOnFocus | boolean | false | Whether to run a query when input receives focus. | | showClear | boolean | false | When enabled, a clear icon is displayed to clear the value. | | dropdown | boolean | false | Displays a button next to the input field when enabled. | | showEmptyMessage | boolean | true | Whether to show the empty message or not. | | dropdownMode | string | blank | Specifies the behavior dropdown button. Default "blank" mode sends an empty string and "current" mode sends the input value. | | multiple | boolean | false | Specifies if multiple values can be selected. | | addOnTab | boolean | false | When enabled, the input value is added to the selected items on tab key press when multiple is true and typeahead is false. | | tabindex | number | - | Index of the element in tabbing order. | | dataKey | string | - | A property to uniquely identify a value in options. | | emptyMessage | string | - | Text to display when there is no data. Defaults to global value in i18n translation configuration. | | showTransitionOptions | string | .12s cubic-bezier(0, 0, 0.2, 1) | Transition options of the show animation. **(Deprecated)** | | hideTransitionOptions | string | .1s linear | Transition options of the hide animation. **(Deprecated)** | | autofocus | boolean | false | When present, it specifies that the component should automatically get focus on load. | | autocomplete | string | off | Used to define a string that autocomplete attribute the current element. | | optionGroupChildren | string | items | Name of the options field of an option group. | | optionGroupLabel | string | label | Name of the label field of an option group. | | overlayOptions | OverlayOptions | - | Options for the overlay element. | | suggestions | any[] | - | An array of suggestions to display. | | optionLabel | string \| ((item: any) => string) | - | Property name or getter function to use as the label of an option. | | optionValue | string \| ((item: any) => string) | - | Property name or getter function to use as the value of an option. | | id | string | - | Unique identifier of the component. | | searchMessage | string | '{0} results are available' | Text to display when the search is active. Defaults to global value in i18n translation configuration. | | emptySelectionMessage | string | 'No selected item' | Text to display when filtering does not return any results. Defaults to global value in i18n translation configuration. | | selectionMessage | string | '{0} items selected' | Text to be displayed in hidden accessible field when options are selected. Defaults to global value in i18n translation configuration. | | autoOptionFocus | boolean | false | Whether to focus on the first visible or selected element when the overlay panel is shown. | | selectOnFocus | boolean | false | When enabled, the focused option is selected. | | searchLocale | boolean | false | Locale to use in searching. The default locale is the host environment's current locale. | | optionDisabled | string \| ((item: any) => string) | - | Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. | | focusOnHover | boolean | true | When enabled, the hovered option will be focused. | | typeahead | boolean | true | Whether typeahead is active or not. | | addOnBlur | boolean | false | Whether to add an item on blur event if the input has value and typeahead is false with multiple mode. | | separator | string \| RegExp | - | Separator char to add item when typeahead is false and multiple mode is enabled. | | appendTo | InputSignal | 'self' | Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name). | | motionOptions | InputSignal | ... | The motion options. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | | required | InputSignalWithTransform | false | There must be a value (if set). | | invalid | InputSignalWithTransform | false | When present, it specifies that the component should have invalid state style. | | disabled | InputSignalWithTransform | false | When present, it specifies that the component should have disabled state style. | | name | InputSignal | undefined | When present, it specifies that the name of the input. | | fluid | InputSignalWithTransform | false | Spans 100% width of the container when enabled. | | variant | InputSignal<"outlined" \| "filled"> | 'outlined' | Specifies the input variant of the component. | | size | InputSignal<"small" \| "large"> | undefined | Specifies the size of the component. | | inputSize | InputSignal | undefined | Specifies the visible width of the input element in characters. | | pattern | InputSignal | undefined | Specifies the value must match the pattern. | | min | InputSignal | undefined | The value must be greater than or equal to the value. | | max | InputSignal | undefined | The value must be less than or equal to the value. | | step | InputSignal | undefined | Unless the step is set to the any literal, the value must be min + an integral multiple of the step. | | minlength | InputSignal | undefined | The number of characters (code points) must not be less than the value of the attribute, if non-empty. | | maxlength | InputSignal | undefined | The number of characters (code points) must not exceed the value of the attribute. | ### Emits | Name | Parameters | Description | |------|------------|-------------| | completeMethod | event: AutoCompleteCompleteEvent | Callback to invoke to search for suggestions. | | onSelect | event: AutoCompleteSelectEvent | Callback to invoke when a suggestion is selected. | | onUnselect | event: AutoCompleteUnselectEvent | Callback to invoke when a selected value is removed. | | onAdd | event: AutoCompleteAddEvent | Callback to invoke when an item is added via addOnBlur or separator features. | | onFocus | event: Event | Callback to invoke when the component receives focus. | | onBlur | event: Event | Callback to invoke when the component loses focus. | | onDropdownClick | event: AutoCompleteDropdownClickEvent | Callback to invoke to when dropdown button is clicked. | | onClear | event: Event | Callback to invoke when clear button is clicked. | | onInputKeydown | event: KeyboardEvent | Callback to invoke on input key down. | | onKeyUp | event: KeyboardEvent | Callback to invoke on input key up. | | onShow | event: Event | Callback to invoke on overlay is shown. | | onHide | event: Event | Callback to invoke on overlay is hidden. | | onLazyLoad | event: AutoCompleteLazyLoadEvent | Callback to invoke on lazy load data. | ### Templates | Name | Type | Description | |------|------|-------------| | item | TemplateRef> | Custom item template. | | empty | TemplateRef | Custom empty message template. | | header | TemplateRef | Custom header template. | | footer | TemplateRef | Custom footer template. | | selecteditem | TemplateRef> | Custom selected item template. | | group | TemplateRef> | Custom group template. | | loader | TemplateRef | Custom loader template. | | removeicon | TemplateRef | Custom remove icon template. | | loadingicon | TemplateRef | Custom loading icon template. | | clearicon | TemplateRef | Custom clear icon template. | | dropdownicon | TemplateRef | Custom dropdown icon template. | ## Pass Through Options | Name | Type | Description | |------|------|-------------| | host | PassThroughOption | Used to pass attributes to the host's DOM element. | | root | PassThroughOption | Used to pass attributes to the root's DOM element. | | pcInputText | InputTextPassThrough | Used to pass attributes to the InputText component. | | inputMultiple | PassThroughOption | Used to pass attributes to the input multiple's DOM element. | | chipItem | PassThroughOption | Used to pass attributes to the chip item's DOM element. | | pcChip | ChipPassThrough | Used to pass attributes to the Chip component. | | chipIcon | PassThroughOption | Used to pass attributes to the chip icon's DOM element. | | inputChip | PassThroughOption | Used to pass attributes to the input chip's DOM element. | | clearIcon | PassThroughOption | Used to pass attributes to the clear icon's DOM element. | | loader | PassThroughOption | Used to pass attributes to the loader's DOM element. | | dropdown | PassThroughOption | Used to pass attributes to the dropdown button's DOM element. | | pcOverlay | OverlayPassThrough | Used to pass attributes to the Overlay component. | | overlay | PassThroughOption | Used to pass attributes to the overlay's DOM element. | | listContainer | PassThroughOption | Used to pass attributes to the list container's DOM element. | | pcScroller | VirtualScrollerPassThrough | Used to pass attributes to the Scroller component. | | list | PassThroughOption | Used to pass attributes to the list's DOM element. | | optionGroup | PassThroughOption | Used to pass attributes to the option group's DOM element. | | option | PassThroughOption | Used to pass attributes to the option's DOM element. | | emptyMessage | PassThroughOption | Used to pass attributes to the empty message's DOM element. | ## Theming ### CSS Classes | Class | Description | |-------|-------------| | p-autocomplete | Class name of the root element | | p-autocomplete-input | Class name of the input element | | p-autocomplete-input-multiple | Class name of the input multiple element | | p-autocomplete-chip-item | Class name of the chip item element | | p-autocomplete-chip | Class name of the chip element | | p-autocomplete-chip-icon | Class name of the chip icon element | | p-autocomplete-input-chip | Class name of the input chip element | | p-autocomplete-loader | Class name of the loader element | | p-autocomplete-dropdown | Class name of the dropdown element | | p-autocomplete-overlay | Class name of the panel element | | p-autocomplete-list | Class name of the list element | | p-autocomplete-option-group | Class name of the option group element | | p-autocomplete-option | Class name of the option element | | p-autocomplete-empty-message | Class name of the empty message element | | p-autocomplete-clear-icon | Class name of the clear icon | ### Design Tokens | Token | CSS Variable | Description | |-------|--------------|-------------| | autocomplete.background | --p-autocomplete-background | Background of root | | autocomplete.disabled.background | --p-autocomplete-disabled-background | Disabled background of root | | autocomplete.filled.background | --p-autocomplete-filled-background | Filled background of root | | autocomplete.filled.hover.background | --p-autocomplete-filled-hover-background | Filled hover background of root | | autocomplete.filled.focus.background | --p-autocomplete-filled-focus-background | Filled focus background of root | | autocomplete.border.color | --p-autocomplete-border-color | Border color of root | | autocomplete.hover.border.color | --p-autocomplete-hover-border-color | Hover border color of root | | autocomplete.focus.border.color | --p-autocomplete-focus-border-color | Focus border color of root | | autocomplete.invalid.border.color | --p-autocomplete-invalid-border-color | Invalid border color of root | | autocomplete.color | --p-autocomplete-color | Color of root | | autocomplete.disabled.color | --p-autocomplete-disabled-color | Disabled color of root | | autocomplete.placeholder.color | --p-autocomplete-placeholder-color | Placeholder color of root | | autocomplete.invalid.placeholder.color | --p-autocomplete-invalid-placeholder-color | Invalid placeholder color of root | | autocomplete.shadow | --p-autocomplete-shadow | Shadow of root | | autocomplete.padding.x | --p-autocomplete-padding-x | Padding x of root | | autocomplete.padding.y | --p-autocomplete-padding-y | Padding y of root | | autocomplete.border.radius | --p-autocomplete-border-radius | Border radius of root | | autocomplete.focus.ring.width | --p-autocomplete-focus-ring-width | Focus ring width of root | | autocomplete.focus.ring.style | --p-autocomplete-focus-ring-style | Focus ring style of root | | autocomplete.focus.ring.color | --p-autocomplete-focus-ring-color | Focus ring color of root | | autocomplete.focus.ring.offset | --p-autocomplete-focus-ring-offset | Focus ring offset of root | | autocomplete.focus.ring.shadow | --p-autocomplete-focus-ring-shadow | Focus ring shadow of root | | autocomplete.transition.duration | --p-autocomplete-transition-duration | Transition duration of root | | autocomplete.overlay.background | --p-autocomplete-overlay-background | Background of overlay | | autocomplete.overlay.border.color | --p-autocomplete-overlay-border-color | Border color of overlay | | autocomplete.overlay.border.radius | --p-autocomplete-overlay-border-radius | Border radius of overlay | | autocomplete.overlay.color | --p-autocomplete-overlay-color | Color of overlay | | autocomplete.overlay.shadow | --p-autocomplete-overlay-shadow | Shadow of overlay | | autocomplete.list.padding | --p-autocomplete-list-padding | Padding of list | | autocomplete.list.gap | --p-autocomplete-list-gap | Gap of list | | autocomplete.option.focus.background | --p-autocomplete-option-focus-background | Focus background of option | | autocomplete.option.selected.background | --p-autocomplete-option-selected-background | Selected background of option | | autocomplete.option.selected.focus.background | --p-autocomplete-option-selected-focus-background | Selected focus background of option | | autocomplete.option.color | --p-autocomplete-option-color | Color of option | | autocomplete.option.focus.color | --p-autocomplete-option-focus-color | Focus color of option | | autocomplete.option.selected.color | --p-autocomplete-option-selected-color | Selected color of option | | autocomplete.option.selected.focus.color | --p-autocomplete-option-selected-focus-color | Selected focus color of option | | autocomplete.option.padding | --p-autocomplete-option-padding | Padding of option | | autocomplete.option.border.radius | --p-autocomplete-option-border-radius | Border radius of option | | autocomplete.option.group.background | --p-autocomplete-option-group-background | Background of option group | | autocomplete.option.group.color | --p-autocomplete-option-group-color | Color of option group | | autocomplete.option.group.font.weight | --p-autocomplete-option-group-font-weight | Font weight of option group | | autocomplete.option.group.padding | --p-autocomplete-option-group-padding | Padding of option group | | autocomplete.dropdown.width | --p-autocomplete-dropdown-width | Width of dropdown | | autocomplete.dropdown.sm.width | --p-autocomplete-dropdown-sm-width | Sm width of dropdown | | autocomplete.dropdown.lg.width | --p-autocomplete-dropdown-lg-width | Lg width of dropdown | | autocomplete.dropdown.border.color | --p-autocomplete-dropdown-border-color | Border color of dropdown | | autocomplete.dropdown.hover.border.color | --p-autocomplete-dropdown-hover-border-color | Hover border color of dropdown | | autocomplete.dropdown.active.border.color | --p-autocomplete-dropdown-active-border-color | Active border color of dropdown | | autocomplete.dropdown.border.radius | --p-autocomplete-dropdown-border-radius | Border radius of dropdown | | autocomplete.dropdown.focus.ring.width | --p-autocomplete-dropdown-focus-ring-width | Focus ring width of dropdown | | autocomplete.dropdown.focus.ring.style | --p-autocomplete-dropdown-focus-ring-style | Focus ring style of dropdown | | autocomplete.dropdown.focus.ring.color | --p-autocomplete-dropdown-focus-ring-color | Focus ring color of dropdown | | autocomplete.dropdown.focus.ring.offset | --p-autocomplete-dropdown-focus-ring-offset | Focus ring offset of dropdown | | autocomplete.dropdown.focus.ring.shadow | --p-autocomplete-dropdown-focus-ring-shadow | Focus ring shadow of dropdown | | autocomplete.dropdown.background | --p-autocomplete-dropdown-background | Background of dropdown | | autocomplete.dropdown.hover.background | --p-autocomplete-dropdown-hover-background | Hover background of dropdown | | autocomplete.dropdown.active.background | --p-autocomplete-dropdown-active-background | Active background of dropdown | | autocomplete.dropdown.color | --p-autocomplete-dropdown-color | Color of dropdown | | autocomplete.dropdown.hover.color | --p-autocomplete-dropdown-hover-color | Hover color of dropdown | | autocomplete.dropdown.active.color | --p-autocomplete-dropdown-active-color | Active color of dropdown | | autocomplete.chip.border.radius | --p-autocomplete-chip-border-radius | Border radius of chip | | autocomplete.chip.focus.background | --p-autocomplete-chip-focus-background | Focus background of chip | | autocomplete.chip.focus.color | --p-autocomplete-chip-focus-color | Focus color of chip | | autocomplete.empty.message.padding | --p-autocomplete-empty-message-padding | Padding of empty message | --- # Angular AutoFocus Directive AutoFocus manages focus on focusable element on load. ## Basic AutoFocus is applied to any focusable input element with the pAutoFocus directive. **Basic Usage:** ```html ``` ## Import
TypeScript Example ```typescript import { AutoFocusModule } from 'primeng/autofocus'; ```
## Auto Focus AutoFocus manages focus on focusable element on load. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | autofocus | boolean | false | When present, it specifies that the component should automatically get focus on load. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | --- # Angular Avatar Component Avatar represents people using icons, labels and images. ## Accessibility Screen Reader Avatar does not include any roles and attributes by default. Any attribute is passed to the root element so you may add a role like img along with aria-labelledby or aria-label to describe the component. In case avatars need to be tabbable, tabIndex can be added as well to implement custom key handlers. Keyboard Support Component does not include any interactive elements. ## AvatarGroup Grouping is available by wrapping multiple Avatar components inside an AvatarGroup . **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { Avatar } from 'primeng/avatar'; import { AvatarGroup } from 'primeng/avatargroup'; @Component({ selector: 'avatar-group-demo', templateUrl: './avatar-group-demo.html', standalone: true, imports: [Avatar, AvatarGroup] }) export class AvatarGroupDemo {} ```
## avatarstyledoc Following is the list of structural style classes, for theming classes visit theming page. ## Badge A badge can be added to an Avatar with the Badge directive. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { Avatar } from 'primeng/avatar'; import { BadgeModule } from 'primeng/badge'; @Component({ selector: 'avatar-badge-demo', templateUrl: './avatar-badge-demo.html', standalone: true, imports: [Avatar, BadgeModule] }) export class AvatarBadgeDemo {} ```
## Icon A font icon is displayed as an Avatar with the icon property. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AvatarModule } from 'primeng/avatar'; import { OverlayBadgeModule } from 'primeng/overlaybadge'; @Component({ selector: 'avatar-icon-demo', templateUrl: './avatar-icon-demo.html', standalone: true, imports: [AvatarModule, OverlayBadgeModule] }) export class AvatarIconDemo {} ```
## Image Use the image property to display an image as an Avatar. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AvatarModule } from 'primeng/avatar'; import { OverlayBadgeModule } from 'primeng/overlaybadge'; @Component({ selector: 'avatar-image-demo', templateUrl: './avatar-image-demo.html', standalone: true, imports: [AvatarModule, OverlayBadgeModule] }) export class AvatarImageDemo {} ```
## Import
TypeScript Example ```typescript import { AvatarModule } from 'primeng/avatar'; import { AvatarGroupModule } from 'primeng/avatargroup'; ```
## Label A letter Avatar is defined with the label property. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { AvatarModule } from 'primeng/avatar'; import { OverlayBadgeModule } from 'primeng/overlaybadge'; @Component({ selector: 'avatar-label-demo', templateUrl: './avatar-label-demo.html', standalone: true, imports: [AvatarModule, OverlayBadgeModule] }) export class AvatarLabelDemo {} ```
## Shape Avatar comes in two different styles specified with the shape property, square is the default and circle is the alternative. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { Avatar } from 'primeng/avatar'; @Component({ selector: 'avatar-shape-demo', templateUrl: './avatar-shape-demo.html', standalone: true, imports: [Avatar] }) export class AvatarShapeDemo {} ```
## Size size property defines the size of the Avatar with large and xlarge as possible values. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { Avatar } from 'primeng/avatar'; @Component({ selector: 'avatar-size-demo', templateUrl: './avatar-size-demo.html', standalone: true, imports: [Avatar] }) export class AvatarSizeDemo {} ```
## Template Content can easily be customized with the dynamic content instead of using the built-in modes. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { Avatar } from 'primeng/avatar'; @Component({ selector: 'avatar-template-demo', templateUrl: './avatar-template-demo.html', standalone: true, imports: [Avatar] }) export class AvatarTemplateDemo {} ```
## Avatar Avatar represents people using icons, labels and images. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | label | string | - | Defines the text to display. | | icon | string | - | Defines the icon to display. | | image | string | - | Defines the image to display. | | size | "large" \| "xlarge" \| "normal" | normal | Size of the element. | | shape | "circle" \| "square" | square | Shape of the element. | | styleClass | string | - | Class of the element. **(Deprecated)** | | ariaLabel | string | - | Establishes a string value that labels the component. | | ariaLabelledBy | string | - | Establishes relationships between the component and label(s) where its value should be one or more element IDs. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | ### Emits | Name | Parameters | Description | |------|------------|-------------| | onImageError | event: Event | This event is triggered if an error occurs while loading an image file. | ## Pass Through Options | Name | Type | Description | |------|------|-------------| | host | PassThroughOption | Used to pass attributes to the host's DOM element. | | root | PassThroughOption | Used to pass attributes to the root's DOM element. | | label | PassThroughOption | Used to pass attributes to the label's DOM element. | | icon | PassThroughOption | Used to pass attributes to the icon's DOM element. | | image | PassThroughOption | Used to pass attributes to the image's DOM element. | ## Theming ### CSS Classes | Class | Description | |-------|-------------| | p-avatar | Class name of the root element | | p-avatar-label | Class name of the label element | | p-avatar-icon | Class name of the icon element | | p-avatar-image | Container element in image mode | | p-avatar-circle | Container element with a circle shape | | p-avatar-lg | Container element with a large size | | p-avatar-xl | Container element with an xlarge size | ### Design Tokens | Token | CSS Variable | Description | |-------|--------------|-------------| | avatar.width | --p-avatar-width | Width of root | | avatar.height | --p-avatar-height | Height of root | | avatar.font.size | --p-avatar-font-size | Font size of root | | avatar.background | --p-avatar-background | Background of root | | avatar.color | --p-avatar-color | Color of root | | avatar.border.radius | --p-avatar-border-radius | Border radius of root | | avatar.icon.size | --p-avatar-icon-size | Size of icon | | avatar.group.border.color | --p-avatar-group-border-color | Border color of group | | avatar.group.offset | --p-avatar-group-offset | Offset of group | | avatar.lg.width | --p-avatar-lg-width | Width of lg | | avatar.lg.height | --p-avatar-lg-height | Height of lg | | avatar.lg.font.size | --p-avatar-lg-font-size | Font size of lg | | avatar.lg.icon.size | --p-avatar-lg-icon-size | Icon size of lg | | avatar.lg.group.offset | --p-avatar-lg-group-offset | Group offset of lg | | avatar.xl.width | --p-avatar-xl-width | Width of xl | | avatar.xl.height | --p-avatar-xl-height | Height of xl | | avatar.xl.font.size | --p-avatar-xl-font-size | Font size of xl | | avatar.xl.icon.size | --p-avatar-xl-icon-size | Icon size of xl | | avatar.xl.group.offset | --p-avatar-xl-group-offset | Group offset of xl | --- # Angular Badge Component Badge is a small status indicator for another element. ## Accessibility Screen Reader Badge does not include any roles and attributes by default, any attribute is passed to the root element so aria roles and attributes can be added if required. If the badges are dynamic, aria-live may be utilized as well. In case badges need to be tabbable, tabIndex can be added to implement custom key handlers. Keyboard Support Component does not include any interactive elements. ## Basic Content of the badge is specified using the value property. **Basic Usage:** ```html ``` ## Button Buttons have built-in support for badges to display a badge inline. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'badge-button-demo', templateUrl: './badge-button-demo.html', standalone: true, imports: [ButtonModule] }) export class BadgeButtonDemo {} ```
## directivedoc Content of the badge is specified using the value property. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { BadgeModule } from 'primeng/badge'; @Component({ selector: 'badge-directive-demo', templateUrl: './badge-directive-demo.html', standalone: true, imports: [BadgeModule] }) export class BadgeDirectiveDemo {} ```
## Import
TypeScript Example ```typescript import { BadgeModule } from 'primeng/badge'; import { OverlayBadgeModule } from 'primeng/overlaybadge'; ```
## Overlay A badge can be added to any element by encapsulating the content with the OverlayBadge component. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { OverlayBadgeModule } from 'primeng/overlaybadge'; @Component({ selector: 'badge-overlay-demo', templateUrl: './badge-overlay-demo.html', standalone: true, imports: [OverlayBadgeModule] }) export class BadgeOverlayDemo {} ```
## positiondoc A Badge can be positioned at the top right corner of an element by adding p-overlay-badge style class to the element and embedding the badge inside. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { BadgeModule } from 'primeng/badge'; @Component({ selector: 'badge-position-demo', templateUrl: './badge-position-demo.html', standalone: true, imports: [BadgeModule] }) export class BadgePositionDemo {} ```
## Severity Severity defines the color of the badge, possible values are success , info , warn and danger **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { BadgeModule } from 'primeng/badge'; @Component({ selector: 'badge-severity-demo', templateUrl: './badge-severity-demo.html', standalone: true, imports: [BadgeModule] }) export class BadgeSeverityDemo {} ```
## Size Badge sizes are adjusted with the badgeSize property that accepts small , large and xlarge as the possible alternatives to the default size. Currently sizes only apply to component mode. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { BadgeModule } from 'primeng/badge'; @Component({ selector: 'badge-size-demo', templateUrl: './badge-size-demo.html', standalone: true, imports: [BadgeModule] }) export class BadgeSizeDemo {} ```
## styledoc Following is the list of structural style classes, for theming classes visit theming page. ## Badge Directive Badge Directive is directive usage of badge component. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | ptBadgeDirective | InputSignal | undefined | Used to pass attributes to DOM elements inside the Badge component. **(Deprecated)** | | pBadgePT | InputSignal | undefined | Used to pass attributes to DOM elements inside the Badge component. | | pBadgeUnstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | disabled | boolean | false | When specified, disables the component. | | badgeSize | "small" \| "large" \| "xlarge" | - | Size of the badge, valid options are "large" and "xlarge". | | size | "small" \| "large" \| "xlarge" | - | Size of the badge, valid options are "large" and "xlarge". **(Deprecated)** | | severity | "success" \| "info" \| "warn" \| "danger" \| "secondary" \| "contrast" | - | Severity type of the badge. | | value | string \| number | - | Value to display inside the badge. | | badgeStyle | { [klass: string]: any } | - | Inline style of the element. | | badgeStyleClass | string | - | Class of the element. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | ## Badge Badge is a small status indicator for another element. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | styleClass | InputSignal | ... | Class of the element. **(Deprecated)** | | badgeSize | InputSignal<"small" \| "large" \| "xlarge"> | ... | Size of the badge, valid options are "large" and "xlarge". | | size | InputSignal<"small" \| "large" \| "xlarge"> | ... | Size of the badge, valid options are "large" and "xlarge". | | severity | InputSignal<"success" \| "info" \| "warn" \| "danger" \| "secondary" \| "contrast"> | ... | Severity type of the badge. | | value | InputSignal | ... | Value to display inside the badge. | | badgeDisabled | InputSignalWithTransform | ... | When specified, disables the component. | | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | ## Pass Through Options | Name | Type | Description | |------|------|-------------| | host | PassThroughOption | Used to pass attributes to the host's DOM element. | | root | PassThroughOption | Used to pass attributes to the root's DOM element. | ## Theming ### CSS Classes | Class | Description | |-------|-------------| | p-badge | Class name of the root element | ### Design Tokens | Token | CSS Variable | Description | |-------|--------------|-------------| | badge.border.radius | --p-badge-border-radius | Border radius of root | | badge.padding | --p-badge-padding | Padding of root | | badge.font.size | --p-badge-font-size | Font size of root | | badge.font.weight | --p-badge-font-weight | Font weight of root | | badge.min.width | --p-badge-min-width | Min width of root | | badge.height | --p-badge-height | Height of root | | badge.dot.size | --p-badge-dot-size | Size of dot | | badge.sm.font.size | --p-badge-sm-font-size | Font size of sm | | badge.sm.min.width | --p-badge-sm-min-width | Min width of sm | | badge.sm.height | --p-badge-sm-height | Height of sm | | badge.lg.font.size | --p-badge-lg-font-size | Font size of lg | | badge.lg.min.width | --p-badge-lg-min-width | Min width of lg | | badge.lg.height | --p-badge-lg-height | Height of lg | | badge.xl.font.size | --p-badge-xl-font-size | Font size of xl | | badge.xl.min.width | --p-badge-xl-min-width | Min width of xl | | badge.xl.height | --p-badge-xl-height | Height of xl | | badge.primary.background | --p-badge-primary-background | Background of primary | | badge.primary.color | --p-badge-primary-color | Color of primary | | badge.secondary.background | --p-badge-secondary-background | Background of secondary | | badge.secondary.color | --p-badge-secondary-color | Color of secondary | | badge.success.background | --p-badge-success-background | Background of success | | badge.success.color | --p-badge-success-color | Color of success | | badge.info.background | --p-badge-info-background | Background of info | | badge.info.color | --p-badge-info-color | Color of info | | badge.warn.background | --p-badge-warn-background | Background of warn | | badge.warn.color | --p-badge-warn-color | Color of warn | | badge.danger.background | --p-badge-danger-background | Background of danger | | badge.danger.color | --p-badge-danger-color | Color of danger | | badge.contrast.background | --p-badge-contrast-background | Background of contrast | | badge.contrast.color | --p-badge-contrast-color | Color of contrast | --- # Angular BlockUI Component BlockUI can either block other components or the whole page. ## Accessibility Screen Reader BlockUI manages aria-busy state attribute when the UI gets blocked and unblocked. Any valid attribute is passed to the root element so additional attributes like role and aria-live can be used to define live regions. Keyboard Support Component does not include any interactive elements. ## Basic The element to block should be placed as a child of BlockUI and blocked property is required to control the state. **Basic Usage:** ```html

Lorem ipsum dolor sit amet, consectetur adipiscing elit...

``` ## Document If the target element is not specified, BlockUI blocks the document by default. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component, ChangeDetectorRef } from '@angular/core'; import { BlockUI } from 'primeng/blockui'; import { ButtonModule } from 'primeng/button'; import { Ripple } from 'primeng/ripple'; @Component({ selector: 'block-ui-document-demo', templateUrl: './block-ui-document-demo.html', standalone: true, imports: [BlockUI, ButtonModule, Ripple] }) export class BlockUiDocumentDemo { blockedDocument: boolean = false; constructor(private cd: ChangeDetectorRef) {} blockDocument() { this.blockedDocument = true; setTimeout(() => { this.blockedDocument = false; this.cd.markForCheck(); }, 3000); } } ```
## Import
TypeScript Example ```typescript import { BlockUIModule } from 'primeng/blockui'; ```
## styledoc Following is the list of structural style classes, for theming classes visit theming page. ## Block U I BlockUI can either block other components or the whole page. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | | target | any | - | Name of the local ng-template variable referring to another component. | | autoZIndex | boolean | true | Whether to automatically manage layering. | | baseZIndex | number | 0 | Base zIndex value to use in layering. | | styleClass | string | - | Class of the element. **(Deprecated)** | | blocked | boolean | - | Current blocked state as a boolean. | ### Templates | Name | Type | Description | |------|------|-------------| | content | TemplateRef | template of the content | ## Pass Through Options | Name | Type | Description | |------|------|-------------| | host | PassThroughOption | Used to pass attributes to the host's DOM element. | | root | PassThroughOption | Used to pass attributes to the root's DOM element. | ## Theming ### CSS Classes | Class | Description | |-------|-------------| | p-blockui | Class name of the root element | ### Design Tokens | Token | CSS Variable | Description | |-------|--------------|-------------| | blockui.border.radius | --p-blockui-border-radius | Border radius of root | --- # Angular Breadcrumb Component Breadcrumb provides contextual information about page hierarchy. ## Accessibility Screen Reader Breadcrumb uses the nav element and since any attribute is passed to the root implicitly aria-labelledby or aria-label can be used to describe the component. Inside an ordered list is used where the list item separators have aria-hidden to be able to ignored by the screen readers. If the last link represents the current route, aria-current is added with "page" as the value. Keyboard Support No special keyboard interaction is needed, all menuitems are focusable based on the page tab sequence. ## Basic Breadcrumb provides contextual information about page hierarchy. **Basic Usage:** ```html ``` ## Import
TypeScript Example ```typescript import { BreadcrumbModule } from 'primeng/breadcrumb'; ```
## Router Menu items support navigation via routerLink, programmatic routing using commands, or external URLs. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component, OnInit } from '@angular/core'; import { MenuItem } from 'primeng/api'; import { Breadcrumb } from 'primeng/breadcrumb'; import { RouterModule } from '@angular/router'; @Component({ selector: 'breadcrumb-router-demo', templateUrl: './breadcrumb-router-demo.html', standalone: true, imports: [Breadcrumb, RouterModule] }) export class BreadcrumbRouterDemo { items: MenuItem[] = [{ label: 'Components' }, { label: 'Form' }, { label: 'InputText', routerLink: '/inputtext' }]; home: MenuItem = { icon: 'pi pi-home', routerLink: '/' }; } ```
## styledoc Following is the list of structural style classes, for theming classes visit theming page. ## Template Custom content can be placed inside the items using the item template. The divider between the items has its own separator template. **Basic Usage:** ```html / ```
TypeScript Example ```typescript import { Component, OnInit } from '@angular/core'; import { MenuItem } from 'primeng/api'; import { Breadcrumb } from 'primeng/breadcrumb'; import { RouterModule } from '@angular/router'; @Component({ selector: 'breadcrumb-template-demo', templateUrl: './breadcrumb-template-demo.html', standalone: true, imports: [Breadcrumb, RouterModule] }) export class BreadcrumbTemplateDemo implements OnInit { items: MenuItem[] | undefined; home: MenuItem | undefined; ngOnInit() { this.items = [{ icon: 'pi pi-sitemap' }, { icon: 'pi pi-book' }, { icon: 'pi pi-wallet' }, { icon: 'pi pi-shopping-bag' }, { icon: 'pi pi-calculator' }]; this.home = { icon: 'pi pi-home' }; } } ```
## Breadcrumb Breadcrumb provides contextual information about page hierarchy. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | | model | MenuItem[] | - | An array of menuitems. | | style | { [klass: string]: any } | - | Inline style of the component. | | styleClass | string | - | Style class of the component. | | home | MenuItem | - | MenuItem configuration for the home icon. | | homeAriaLabel | string | - | Defines a string that labels the home icon for accessibility. | ### Emits | Name | Parameters | Description | |------|------------|-------------| | onItemClick | event: BreadcrumbItemClickEvent | Fired when an item is selected. | ### Templates | Name | Type | Description | |------|------|-------------| | item | TemplateRef | Custom item template. | | separator | TemplateRef | Custom separator template. | ## Pass Through Options | Name | Type | Description | |------|------|-------------| | root | PassThroughOption | Used to pass attributes to the root's DOM element. | | list | PassThroughOption | Used to pass attributes to the list's DOM element. | | homeItem | PassThroughOption | Used to pass attributes to the home item's DOM element. | | item | PassThroughOption | Used to pass attributes to the item's DOM element. | | itemLink | PassThroughOption | Used to pass attributes to the item link's DOM element. | | itemIcon | PassThroughOption | Used to pass attributes to the item icon's DOM element. | | itemLabel | PassThroughOption | Used to pass attributes to the item label's DOM element. | | separator | PassThroughOption | Used to pass attributes to the separator's DOM element. | | separatorIcon | PassThroughOption | Used to pass attributes to the separator icon's DOM element. | ## Theming ### CSS Classes | Class | Description | |-------|-------------| | p-breadcrumb | Class name of the root element | | p-breadcrumb-list | Class name of the list element | | p-breadcrumb-home-item | Class name of the home item element | | p-breadcrumb-separator | Class name of the separator element | | p-breadcrumb-item | Class name of the item element | | p-breadcrumb-item-link | Class name of the item link element | | p-breadcrumb-item-icon | Class name of the item icon element | | p-breadcrumb-item-label | Class name of the item label element | ### Design Tokens | Token | CSS Variable | Description | |-------|--------------|-------------| | breadcrumb.padding | --p-breadcrumb-padding | Padding of root | | breadcrumb.background | --p-breadcrumb-background | Background of root | | breadcrumb.gap | --p-breadcrumb-gap | Gap of root | | breadcrumb.transition.duration | --p-breadcrumb-transition-duration | Transition duration of root | | breadcrumb.item.color | --p-breadcrumb-item-color | Color of item | | breadcrumb.item.hover.color | --p-breadcrumb-item-hover-color | Hover color of item | | breadcrumb.item.border.radius | --p-breadcrumb-item-border-radius | Border radius of item | | breadcrumb.item.gap | --p-breadcrumb-item-gap | Gap of item | | breadcrumb.item.icon.color | --p-breadcrumb-item-icon-color | Icon color of item | | breadcrumb.item.icon.hover.color | --p-breadcrumb-item-icon-hover-color | Icon hover color of item | | breadcrumb.item.focus.ring.width | --p-breadcrumb-item-focus-ring-width | Focus ring width of item | | breadcrumb.item.focus.ring.style | --p-breadcrumb-item-focus-ring-style | Focus ring style of item | | breadcrumb.item.focus.ring.color | --p-breadcrumb-item-focus-ring-color | Focus ring color of item | | breadcrumb.item.focus.ring.offset | --p-breadcrumb-item-focus-ring-offset | Focus ring offset of item | | breadcrumb.item.focus.ring.shadow | --p-breadcrumb-item-focus-ring-shadow | Focus ring shadow of item | | breadcrumb.separator.color | --p-breadcrumb-separator-color | Color of separator | --- # Angular Button Component Button is an extension to standard button element with icons and theming. ## Accessibility Screen Reader Button component renders a native button element that implicitly includes any passed prop. Text to describe the button is defined with the aria-label prop, if not present label prop is used as the value. If the button is icon only or custom templating is used, it is recommended to use aria-label so that screen readers would be able to read the element properly. **Basic Usage:** ```html Youtube ``` ## Badge Buttons have built-in badge support with badge and badgeClass properties. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-badge-demo', templateUrl: './button-badge-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonBadgeDemo { } ```
## Basic Text to display on a button is defined with the label property. **Basic Usage:** ```html ``` ## Button Group Multiple buttons are grouped when wrapped inside an element with ButtonGroup component. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonGroupModule } from 'primeng/buttongroup'; @Component({ selector: 'button-group-demo', templateUrl: './button-group-demo.html', standalone: true, imports: [ButtonGroupModule] }) export class ButtonGroupDemo { } ```
## buttonsetdoc Multiple buttons are grouped when wrapped inside an element with p-buttonset class. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; @Component({ selector: 'button-set-demo', templateUrl: './button-set-demo.html' }) export class ButtonSetDemo { } ```
## Directive Button can also be used as directive using pButton along with pButtonLabel and pButtonIcon helper directives. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-directive-demo', templateUrl: './button-directive-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonDirectiveDemo { } ```
## Disabled When disabled is present, the element cannot be edited and focused. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-disabled-demo', templateUrl: './button-disabled-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonDisabledDemo { } ```
## Icons Icon of a button is specified with icon property and position is configured using iconPos attribute. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-icons-demo', templateUrl: './button-icons-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonIconsDemo { } ```
## iconsonlydoc Buttons can have icons without labels. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-icon-only-demo', templateUrl: './button-icon-only-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonIconOnlyDemo { } ```
## Import
TypeScript Example ```typescript import { ButtonModule } from 'primeng/button'; ```
## Link A button can be rendered as a link when link property is present, while the pButton directive can be applied on an anchor element to style the link as a button. **Basic Usage:** ```html Angular Website Router Link ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; import { RouterModule } from '@angular/router'; @Component({ selector: 'button-link-demo', templateUrl: './button-link-demo.html', standalone: true, imports: [ButtonModule, RouterModule] }) export class ButtonLinkDemo { } ```
## Loading Busy state is controlled with the loading property. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-loading-demo', templateUrl: './button-loading-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonLoadingDemo { loading: boolean = false; load() { this.loading = true; setTimeout(() => { this.loading = false }, 2000); } } ```
## Outlined Outlined buttons display a border without a background initially. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-outlined-demo', templateUrl: './button-outlined-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonOutlinedDemo { } ```
## Raised Raised buttons display a shadow to indicate elevation. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-raised-demo', templateUrl: './button-raised-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonRaisedDemo { } ```
## Raised Text Text buttons can be displayed as raised for elevation. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-raisedtext-demo', templateUrl: './button-raisedtext-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonRaisedtextDemo { } ```
## Rounded Rounded buttons have a circular border radius. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-rounded-demo', templateUrl: './button-rounded-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonRoundedDemo { } ```
## Severity Severity defines the type of button. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-severity-demo', templateUrl: './button-severity-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonSeverityDemo { } ```
## Sizes Button provides small and large sizes as alternatives to the standard. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-sizes-demo', templateUrl: './button-sizes-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonSizesDemo { } ```
## styledoc Following is the list of structural style classes, for theming classes visit theming page. ## Template Custom content inside a button is defined as children. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-template-demo', templateUrl: './button-template-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonTemplateDemo { } ```
## Text Text buttons are displayed as textual elements. **Basic Usage:** ```html ```
TypeScript Example ```typescript import { Component } from '@angular/core'; import { ButtonModule } from 'primeng/button'; @Component({ selector: 'button-text-demo', templateUrl: './button-text-demo.html', standalone: true, imports: [ButtonModule] }) export class ButtonTextDemo { } ```
## Button Directive Button directive is an extension to button component. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | | ptButtonDirective | InputSignal | undefined | Used to pass attributes to DOM elements inside the Button component. **(Deprecated)** | | pButtonPT | InputSignal | undefined | Used to pass attributes to DOM elements inside the Button component. | | pButtonUnstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | text | boolean | false | Add a textual class to the button without a background initially. | | plain | boolean | false | Add a plain textual class to the button without a background initially. | | raised | boolean | false | Add a shadow to indicate elevation. | | size | "small" \| "large" | - | Defines the size of the button. | | outlined | boolean | false | Add a border class without a background initially. | | rounded | boolean | false | Add a circular border radius to the button. | | iconPos | ButtonIconPosition | left | Position of the icon. | | loadingIcon | string | - | Icon to display in loading state. | | fluid | InputSignalWithTransform | undefined | Spans 100% width of the container when enabled. | | label | string | - | Text of the button. **(Deprecated)** | | icon | string | - | Name of the icon. **(Deprecated)** | | loading | boolean | - | Whether the button is in loading state. | | buttonProps | ButtonProps | - | Used to pass all properties of the ButtonProps to the Button component. **(Deprecated)** | | severity | ButtonSeverity | - | Defines the style of the button. | ## Button Button is an extension to standard button element with icons and theming. ### Props | Name | Type | Default | Description | |------|------|---------|-------------| | dt | InputSignal | undefined | Defines scoped design tokens of the component. | | unstyled | InputSignal | undefined | Indicates whether the component should be rendered without styles. | | pt | InputSignal | undefined | Used to pass attributes to DOM elements inside the component. | | ptOptions | InputSignal | undefined | Used to configure passthrough(pt) options of the component. | | type | string | button | Type of the button. | | badge | string | - | Value of the badge. | | disabled | boolean | false | When present, it specifies that the component should be disabled. | | raised | boolean | false | Add a shadow to indicate elevation. | | rounded | boolean | false | Add a circular border radius to the button. | | text | boolean | false | Add a textual class to the button without a background initially. | | plain | boolean | false | Add a plain textual class to the button without a background initially. | | outlined | boolean | false | Add a border class without a background initially. | | link | boolean | false | Add a link style to the button. | | tabindex | number | - | Add a tabindex to the button. | | size | "small" \| "large" | - | Defines the size of the button. | | variant | "text" \| "outlined" | - | Specifies the variant of the component. | | style | { [klass: string]: any } | - | Inline style of the element. | | styleClass | string | - | Class of the element. | | badgeClass | string | - | Style class of the badge. **(Deprecated)** | | badgeSeverity | "success" \| "info" \| "warn" \| "danger" \| "help" \| "primary" \| "secondary" \| "contrast" | secondary | Severity type of the badge. | | ariaLabel | string | - | Used to define a string that autocomplete attribute the current element. | | autofocus | boolean | false | When present, it specifies that the component should automatically get focus on load. | | iconPos | ButtonIconPosition | left | Position of the icon. | | icon | string | - | Name of the icon. | | label | string | - | Text of the button. | | loading | boolean | false | Whether the button is in loading state. | | loadingIcon | string | - | Icon to display in loading state. | | severity | ButtonSeverity | - | Defines the style of the button. | | buttonProps | ButtonProps | - | Used to pass all properties of the ButtonProps to the Button component. | | fluid | InputSignalWithTransform | undefined | Spans 100% width of the container when enabled. | ### Emits | Name | Parameters | Description | |------|------------|-------------| | onClick | event: MouseEvent | Callback to execute when button is clicked. This event is intended to be used with the component. Using a regular