The p-modal component can be used as an alert dialog. This is a modal dialog that interrupts the user's workflow to
draw attention to an important message and requires a response.
Open Modal
Some important Heading
Some important Content
AcceptDeny
prev
next
Open in Stackblitz
<!doctype html>
<htmllang="en"class="auto"><head><title></title></head><bodyclass="bg-base"><p-buttontype="button"aria="{'aria-haspopup': 'dialog'}"> Open Modal
</p-button><p-modalaria="{'role': 'alertdialog'}"disable-backdrop-click="true"><p-headingslot="header"size="large"tag="h2"> Some important Heading
</p-heading><p-text> Some important Content
</p-text><p-button-groupslot="footer"><p-buttontype="button"> Accept
</p-button><p-buttontype="button"variant="secondary"> Deny
</p-button></p-button-group></p-modal><script>const pButton = document.querySelector("p-button");
const pModal = document.querySelector("p-modal");
pButton.addEventListener('click', () => (pModal.open = true));
pModal.addEventListener('dismiss', () => (pModal.open = false));
</script></body></html>
The modal component has some values which can be overwritten by CSS Custom Properties (aka CSS Variables). This might be
useful for e.g. a "Cookie Consent Dialog" to reserve certain space when used with backdrop: 'shading' to always have
the Porsche crest or wordmark visible in the background of the page. Since
the modal is centered within the viewport and shrinks to its content, the custom vertical spacing definition will act
like a safe zone.
In addition, it's possible to make containers or elements (e.g. div, img etc.) stretch into the padding safe-zone by
adding the CSS class.
// the modal comes with predefined margin / safe-zone which needs to be considered when a custom width is defined--p-modal-width: clamp(276px, 45.25vw + 131px, 1000px);
--p-modal-spacing-top: 200px;
--p-modal-spacing-bottom: 50px;