Inplace provides an easy to do editing and display at the same time where clicking the output displays the actual content.
import { Inplace } from 'primereact/inplace';
<Inplace>
<Inplace.Display></Inplace.Display>
<Inplace.Content></Inplace.Content>
</Inplace>
import { Inplace } from 'primereact/inplace';
export default function BasicDemo() {
return (
<div className="card">
<Inplace>
<Inplace.Display>View Content</Inplace.Display>
<Inplace.Content>
<p>
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>
</Inplace.Content>
</Inplace>
</div>
);
}
Use the Inplace.Close
component to close the inplace content.
import { Button } from 'primereact/button';
import { Inplace } from 'primereact/inplace';
import { InputText } from 'primereact/inputtext';
export default function InputDemo() {
return (
<div className="card">
<Inplace>
<Inplace.Display>Click to Edit</Inplace.Display>
<Inplace.Content>
<span className="inline-flex items-center gap-2">
<InputText autoFocus />
<Inplace.Close as={Button} iconOnly role="button" text severity="danger">
<i className="pi pi-times"></i>
</Inplace.Close>
</span>
</Inplace.Content>
</Inplace>
</div>
);
}
Any content such as an image can be placed inside the Inplace.Content
component.
import { Inplace } from 'primereact/inplace';
export default function ImageDemo() {
return (
<div className="card">
<Inplace>
<Inplace.Display>
<span className="pi pi-image mr-2"></span>
<span>View Photo</span>
</Inplace.Display>
<Inplace.Content>
<img className="w-full sm:w-80 shadow-md" alt="Nature" src="https://primefaces.org/cdn/primevue/images/nature/nature8.jpg" />
</Inplace.Content>
</Inplace>
</div>
);
}
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.
Key | Function |
---|---|
enter | Switches to content. |