Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.
import { InplaceModule } from 'primeng/inplace';
Inplace component requires display and content templates to define the content of each state.
<p-inplace>
<ng-template pTemplate="display">
<span>View Content</span>
</ng-template>
<ng-template pTemplate="content">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
</span>
</ng-template>
</p-inplace>
Inplace can be used within a form to display a value as read only before making it editable. The closable property adds a close button next to the content to switch back to read only mode.
<p-inplace closable="closable">
<ng-template pTemplate="display">
<span>Click to Edit</span>
</ng-template>
<ng-template pTemplate="content">
<input type="text" value="PrimeNG" pInputText />
</ng-template>
</p-inplace>
Any content such as an image can be placed inside an Inplace.
<p-inplace>
<ng-template pTemplate="display">
<div class="inline-flex align-items-center">
<span class="pi pi-image" style="vertical-align: middle"></span>
<span class="ml-2">View Picture</span>
</div>
</ng-template>
<ng-template pTemplate="content">
<img
src="https://primefaces.org/cdn/primeng/images/demo/galleria/galleria5.jpg"
alt="Nature" />
</ng-template>
</p-inplace>
Using the onActivate event, data can be loaded in a lazy manner before displaying it in a table.
<p-inplace (onActivate)="loadData()">
<ng-template pTemplate="display">
<span>View Data</span>
</ng-template>
<ng-template pTemplate="content">
<p-table [value]="products" responsiveLayout="scroll">
<ng-template pTemplate="header">
<tr>
<th>Code</th>
<th>Name</th>
<th>Category</th>
<th>Quantity</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-product>
<tr>
<td>{{ product.code }}</td>
<td>{{ product.name }}</td>
<td>{{ product.category }}</td>
<td>{{ product.quantity }}</td>
</tr>
</ng-template>
</p-table>
</ng-template>
</p-inplace>
<p-inplace>
<ng-template pTemplate="display">
<div class="inline-flex align-items-center">
<span class="pi pi-table" style="vertical-align: middle"></span>
<span class="ml-2">View Data</span>
</div>
</ng-template>
<ng-template pTemplate="content">
<p-table [value]="cars" responsiveLayout="scroll">
<ng-template pTemplate="header">
<tr>
<th>Vin</th>
<th>Year</th>
<th>Brand</th>
<th>Color</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-car>
<tr>
<td>{{ car.vin }}</td>
<td>{{ car.year }}</td>
<td>{{ car.brand }}</td>
<td>{{ car.color }}</td>
</tr>
</ng-template>
</p-table>
</ng-template>
</p-inplace>
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-inplace | Container element |
p-inplace-display | Display container |
p-inplace-content | Content container |
Inplace component defines aria-live as "polite" by default, since any valid attribute is passed to the main container aria roles and attributes of the root element can be customized easily.
Display element uses button role in view mode by default, displayProps can be used for customizations like adding aria-label or aria-labelledby attributes to describe the content of the view mode or even overriding the default role.
Closable inplace components displays a button with an aria-label that refers to the aria.close property of the locale API by default, you may usecloseButtonProps to customize the element and override the default aria-label.
Key | Function |
---|---|
enter | Switches to content. |
Key | Function |
---|---|
enter | Switches to display. |
space | Switches to display. |
API defines helper props, events and others for the PrimeNG Inplace module.
Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.
Defines the input properties of the component.
Defines emit that determine the behavior of the component based on a given condition or report the actions that the component takes.
Defines methods that can be accessed by the component's reference.
Defines the templates used by the component.