BlockUIBlockUI can either block other components or the whole page.
Documentation
Import
import {BlockUIModule} from 'primeng/blockui';
Getting Started
BlockUI is controlled using the blocked property and component to block is defined as target. If target is not provided, document itself is selected as the block target.
export class BlockUIDemo {
blocked: boolean;
}
<p-blockUI [blocked]="blocked"></p-blockUI>
To block a certain component, define a local ng-template variable and bind it to the target option. The target component must implement the BlockableUI interface, otherwise an exception is thrown.
<p-blockUI [blocked]="blockedDocument" [target]="pnl"></p-blockUI>
<p-panel #pnl header="Panel Header">
Content of Panel
</p-panel>
Custom Content
Blocker mask is customized by simply adding the content inside the component
<p-blockUI [target]="pnl" [blocked]="blockedPanel">
<i class="fa fa-lock fa-5x" style="position:absolute;top:25%;left:50%"></i>
</p-blockUI>
<p-panel #pnl header="Panel Header">
Content of Panel
</p-panel>
Properties
Name | Type | Default | Description |
---|---|---|---|
blocked | boolean | false | Controls the blocked state. |
target | any | document | Name of the local ng-template variable referring to another component. |
baseZIndex | number | 0 | Base zIndex value to use in layering. |
autoZIndex | boolean | true | Whether to automatically manage layering. |
Styling
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
ui-blockui | Container element. |
Dependencies
None.
Source
export class BlockUIDemo {
blockedPanel: boolean = false;
blockedDocument: boolean = false;
blockDocument() {
this.blockedDocument = true;
setTimeout(() => {
this.blockedDocument = false;
}, 3000);
}
}
<h3 class="first">Document</h3>
<p-blockUI [blocked]="blockedDocument"></p-blockUI>
<button type="button" pButton label="Block" (click)="blockDocument()"></button>
<h3>Panel</h3>
<button type="button" pButton label="Block" (click)="blockedPanel=true"></button>
<button type="button" pButton label="Unblock" (click)="blockedPanel=false"></button>
<p-blockUI [target]="pnl" [blocked]="blockedPanel">
<i class="fa fa-lock fa-5x" style="position:absolute;top:25%;left:50%"></i>
</p-blockUI>
<p-panel #pnl header="Godfather I" [style]="{'margin-top':'20px'}">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-panel>