PXD
v0.2.1-dev

Overlay

a floating UI element that renders on top of the main application content to display temporary information, capture user input, or block interaction

Default

<script setup>
import { ref } from 'vue'

const isVisible = ref(false)

function onClickToClose() {
  isVisible.value = false
}
</script>

<template>
  <PButton @click="isVisible = true">Open</PButton>
  <POverlay v-model="isVisible" @click="onClickToClose" />
</template>

Blurred

When variant="blurred" is set, the overlay will be blurred.

<script setup>
import { ref } from 'vue'

const isVisible = ref(false)

function onClickToClose() {
  isVisible.value = false
}
</script>

<template>
  <PButton @click="isVisible = true">Open</PButton>
  <POverlay v-model="isVisible" variant="blurred" @click="onClickToClose" />
</template>

Props

NameTypeDefaultDescription
z-indexnumber-Stacking order of the overlay, applied through the --overlay-index variable
variant'default' | 'blurred' | 'none'-Backdrop treatment; blurred adds a backdrop blur, none renders no backdrop at all so only the slotted content is placed
model-valuebooleanfalseWhether the overlay is visible
close-on-press-escapebooleantrueClose the overlay when Esc is pressed
close-on-click-overlaybooleanfalseClose the overlay when the backdrop is clicked
lock-scroll-on-visiblebooleantruePrevent the page behind the overlay from scrolling

Events

NameTypeDescription
click(event: PointerEvent) => voidEmitted when the backdrop is clicked.
escape(event: KeyboardEvent) => voidEmitted when Escape reaches this overlay: either it is the topmost one, or every overlay above it left the event unconsumed. Call event.preventDefault() to keep the overlay open.
update:model-value(value: boolean) => voidEmitted with false after Escape unless the escape handler prevented it, or after a backdrop click when close-on-click-overlay is set.

Slots

NameDescription
defaultDefault slot

Source

Source