Inplace

Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.


import Inplace from 'primevue/inplace';

Inplace component requires display and content templates to define the content of each state.

View Content

<Inplace>
    <template #display> View Content </template>
    <template #content>
        <p class="m-0">
            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.
        </p>
    </template>
</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.

Click to Edit

<Inplace :closable="true">
    <template #display>
        {{ text || 'Click to Edit' }}
    </template>
    <template #content>
        <InputText v-model="text" autofocus />
    </template>
</Inplace>

Any content such as an image can be placed inside an Inplace.

View Picture

<Inplace>
    <template #display>
        <span class="pi pi-search" style="vertical-align: middle"></span>
        <span style="margin-left: 0.5rem; vertical-align: middle">View Picture</span>
    </template>
    <template #content>
        <img class="w-full" alt="Nature" src="/images/nature/nature1.jpg" />
    </template>
</Inplace>

Using the open event, data can be loaded in a lazy manner before displaying it in a table.

View Data

<Inplace @open="loadData">
    <template #display> View Data </template>
    <template #content>
        <DataTable :value="products">
            <Column field="code" header="Code"></Column>
            <Column field="name" header="Name"></Column>
            <Column field="category" header="Category"></Column>
            <Column field="quantity" header="Quantity"></Column>
        </DataTable>
    </template>
</Inplace>

Screen Reader

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 use closeButtonProps to customize the element and override the default aria-label.

View Mode Keyboard Support

KeyFunction
enterSwitches to content.

Close Button Keyboard Support

KeyFunction
enterSwitches to display.
spaceSwitches to display.