Skip to content

Modal ​

te-modal is a native <dialog> opened with showModal(), so it renders in the browser's top layer: never clipped by a parent's overflow and never in a z-index fight. The browser also supplies the behaviour a hand-rolled overlay has to reimplement — Esc closes it, focus is trapped inside while it is open and returned to whatever opened it on close, and the rest of the page is inert.

Usage ​

Not shown inline — it covers the page.

vue
<te-button @click="open = true">Open</te-button>

<te-modal v-model:visible="open" title="Delete this item?">
  This cannot be undone.
  <template #footer>
    <te-button type="light" @click="open = false">Cancel</te-button>
    <te-button type="danger" @click="open = false">Delete</te-button>
  </template>
</te-modal>

Props ​

PropTypeDefaultDescription
visiblebooleanfalseSupports v-model:visible.
titlestring''Header text, and the accessible name.
size'' | 'sm' | 'lg' | 'xl'''Dialog width.
centeredbooleanfalseVertically centred.
scrollablebooleanfalseScrolls the body instead of the page.
showCloseButtonbooleantrueClose button in the header.
closeOnBackdropbooleantrueClicking the backdrop closes it. Esc always closes it regardless — that one is not negotiable for accessibility.
hideHeader / hideFooterbooleanfalseDrops that section.
componentComponent | stringundefinedRenders a component in the body instead of the slot.
componentProps / componentEventsobject{}Bound to that component.

Events ​

EventPayloadDescription
update:visiblebooleanVisibility changed.
close—The modal closed, by any route: the button, the backdrop, Esc, or the model.

Slots ​

SlotPropsDescription
default—Body.
header—Replaces the title.
footer—Footer.