PrimeNG UI Suite for Angular
website·Indexed 34 days ago
https://v17.primeng.orgA comprehensive UI component suite for Angular. This documentation for v17 covers a wide range of components including Paginator, FileUpload, Galleria, Carousel, and TabMenu, as well as global configuration, theming, accessibility guides, and localization using the Locale API from @primeng/config.
What's inside PrimeNG
- PrimeNG is a comprehensive suite of customizable and feature-rich UI components for Angular applications. It is built on a design-agnostic infrastructure, allowing developers to use various themes including Material, Bootstrap, Tailwind, and PrimeOne, or create their own custom themes. The library supports both styled and unstyled modes.
Overview of PrimeNG UI Suite
PrimeNG is a comprehensive suite of customizable and feature-rich UI components designed for Angular applications. It is built on a design-agnostic infrastructure, allowing developers to use various themes or create their own.Overview of PrimeNG UI Suite
PrimeNG is a comprehensive suite of customizable and feature-rich UI components for Angular applications. It is built on a design-agnostic infrastructure, allowing developers to use various themes including Material, Bootstrap, Tailwind, and PrimeOne, or create their own custom themes. The library supports both styled and unstyled modes.Understand PrimeNG Theming Architecture
PrimeNG uses a design-agnostic architecture that separates styling into two parts:
- Core: Resides inside PrimeNG and implements the structure and positioning of components.
- Theme: Provides the colors and spacing.
This separation allows PrimeNG to support various design systems (like Material or Bootstrap) without enforcing a specific look.
PrimeNG Accessibility Compliance Overview
PrimeNG components are designed with WCAG 2.1 AA level compliance. For detailed accessibility information regarding specific components, developers should refer to the accessibility documentation provided for each individual component.Configure MeterGroup custom templates
The MeterGroup component provides several template slots to customize the rendering of labels, meter items, icons, and the start/end of the group. Each template receives a specific context object containing data about the current item and the overall group state.<!-- Example of using a custom meter template --> <p-meterGroup [value]="data"> <ng-template pTemplate="meter" let-item> <div [class]="item.class" [style.width]="item.size"> {{ item.$implicit.label }} </div> </ng-template> </p-meterGroup>
PickList event payload definitions
The PickList component uses specific event interfaces to provide data about the action performed. Most movement and reordering events return anitemsarray of the affected elements. Selection events include theoriginalEvent(browser event) and theitemsarray. Filter events provide thequerystring and the resultingvalue(filtered items array).Handle ConfirmDialog hide events
TheConfirmDialogcomponent emits theonHideevent when the dialog is closed. This event provides aConfirmEventTypeobject containing details about the closure.<p-confirmDialog (onHide)="onDialogHide($event)"></p-confirmDialog>Use ScrollerItemOptions for item-level styling and logic
When using the
itemtemplate, theScrollerItemOptionsinterface provides metadata about the specific item being rendered, which is useful for conditional styling or logic:index: The numeric index of the item.count: Total item count.first: Boolean indicating if this is the first element in the viewport.last: Boolean indicating if this is the last element in the viewport.even/odd: Booleans indicating if the index is even or odd.
Use the PrimeNG Divider component
Thep-dividercomponent is used to separate content visually. It supports both horizontal and vertical orientations, various border styles (solid, dashed, dotted), and content alignment.Implement virtual scrolling in PrimeNG Table
To handle large datasets efficiently, use virtual scrolling by enablingvirtualScrolland specifying thevirtualScrollItemSize. When combined withlazyloading and theonLazyLoadevent, the table can fetch data in chunks as the user scrolls. Use theloadingbodytemplate to display skeleton screens while data is being loaded.<p-table [value]="virtualCars" [scrollable]="true" scrollHeight="400px" [rows]="100" [virtualScroll]="true" [virtualScrollItemSize]="46" [lazy]="true" (onLazyLoad)="loadCarsLazy($event)"> <ng-template pTemplate="header" let-columns> <tr> <th *ngFor="let col of columns" style="width: 20%;"> {{col.header}} </th> </tr> </ng-template> <ng-template pTemplate="body" let-rowData let-columns="columns"> <tr style="height:46px"> <td *ngFor="let col of columns"> {{rowData[col.field]}} </td> </tr> </ng-template> <ng-template pTemplate="loadingbody" let-columns="columns"> <tr style="height:46px"> <td *ngFor="let col of columns; let even = even"> <p-skeleton [ngStyle]="{'width': even ? (col.field === 'year' ? '30%' : '40%') : '60%'}" /> </td> </tr> </ng-template> </p-table>Integrate ContextMenu with Angular Router
To support navigation within a ContextMenu, use a customitemtemplate. Check if the menu item has arouteproperty to apply[routerLink]; otherwise, use a standard[href]for external URLs.<p-contextMenu [target]="span" [model]="items"> <ng-template pTemplate="item" let-item> <ng-container *ngIf="item.route; else elseBlock"> <a [routerLink]="item.route" class="p-menuitem-link"> <span [class]="item.icon"></span> <span class="ml-2">{{ item.label }}</span> </a> </ng-container> <ng-template #elseBlock> <a [href]="item.url" class="p-menuitem-link"> <span [class]="item.icon"></span> <span class="ml-2">{{ item.label }}</span> </a> </ng-template> </ng-template> </p-contextMenu>