PrimeNG UI Suite for Angular

website·Indexed 34 days ago

https://v17.primeng.org

A 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.

Tokens
159.2K
Snippets
976
Records
1.3K
Agent score
50%

What's inside PrimeNG

  1. Overview of PrimeNG UI Suite for Angular

    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.
  2. 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.
  3. 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.
  4. Understand PrimeNG Theming Architecture

    PrimeNG uses a design-agnostic architecture that separates styling into two parts:

    1. Core: Resides inside PrimeNG and implements the structure and positioning of components.
    2. Theme: Provides the colors and spacing.

    This separation allows PrimeNG to support various design systems (like Material or Bootstrap) without enforcing a specific look.

  5. 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.
  6. 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>

  7. PickList event payload definitions

    The PickList component uses specific event interfaces to provide data about the action performed. Most movement and reordering events return an items array of the affected elements. Selection events include the originalEvent (browser event) and the items array. Filter events provide the query string and the resulting value (filtered items array).
  8. Handle ConfirmDialog hide events

    The ConfirmDialog component emits the onHide event when the dialog is closed. This event provides a ConfirmEventType object containing details about the closure.
    <p-confirmDialog (onHide)="onDialogHide($event)"></p-confirmDialog>
  9. Use ScrollerItemOptions for item-level styling and logic

    When using the item template, the ScrollerItemOptions interface 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.
  10. Use the PrimeNG Divider component

    The p-divider component is used to separate content visually. It supports both horizontal and vertical orientations, various border styles (solid, dashed, dotted), and content alignment.
  11. Implement virtual scrolling in PrimeNG Table

    To handle large datasets efficiently, use virtual scrolling by enabling virtualScroll and specifying the virtualScrollItemSize. When combined with lazy loading and the onLazyLoad event, the table can fetch data in chunks as the user scrolls. Use the loadingbody template 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>
  12. Integrate ContextMenu with Angular Router

    To support navigation within a ContextMenu, use a custom item template. Check if the menu item has a route property 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>