Components

Dialog

A modal dialog that appears over the page and traps focus.

A modal panel that overlays the page. Focus is trapped inside while open and restored to the trigger when closed. Screen readers are informed via role="dialog" and aria-modal.

For confirmations requiring a required response, use Alert Dialog instead.

Anatomy

  • #trigger: Element that opens the dialog.
  • #overlay: Optional backdrop content behind the dialog.
  • #header: Region containing the title and close control.
  • #title: Dialog accessible title.
  • #description: Supplementary description text.
  • #body: Main content area.
  • #footer: Action buttons.

Usage

Examples

Custom header with close button

Use #header when the close control belongs beside the title.

<template>
  <Dialog>
    <template #trigger="{ toggle }">
      <button @click="() => toggle()">Open</button>
    </template>

    <template #header="{ close, titleId }">
      <h2 :id="titleId">Settings</h2>
      <button aria-label="Close" @click="() => close()"></button>
    </template>

    <template #body>
      <p>Dialog content here.</p>
    </template>
  </Dialog>
</template>

Fullscreen dialog

Use fullscreen for flows that should take over the viewport.

<template>
  <Dialog :fullscreen="true" title="Full view">
    <template #trigger="{ toggle }">
      <button @click="() => toggle()">Expand</button>
    </template>
    <template #body>
      <p>Takes up the entire viewport.</p>
    </template>
  </Dialog>
</template>

Prevent close on backdrop click

Disable backdrop dismissal when the user must make an explicit choice.

<template>
  <Dialog :close-on-backdrop-click="false" title="Required step">
    <template #trigger="{ toggle }">
      <button @click="() => toggle()">Start</button>
    </template>
    <template #footer="{ close }">
      <button @click="() => close()">Complete</button>
    </template>
  </Dialog>
</template>

Programmatic control

Use the exposed API when opening is driven outside the trigger slot.

<script setup lang="ts">
import { ref } from "vue";
import { Dialog } from "akaza-ui";

const dialog = ref();
</script>

<template>
  <Dialog ref="dialog" title="Notification">
    <template #body><p>You have a new message.</p></template>
    <template #footer="{ close }">
      <button @click="() => close()">Dismiss</button>
    </template>
  </Dialog>

  <button @click="dialog?.open()">Show notification</button>
</template>

API Reference

Props

PropTypeDefaultDescription
titlestringConvenience title. Slot #title takes priority.
descriptionstringConvenience description. Slot #description takes priority.
ariaLabelstringFallback accessible name when no title is rendered.
closeOnBackdropClickbooleantrueClose when clicking the overlay.
fullscreenbooleanfalseExpand the dialog to fill the viewport.
teleportstring | false"body"Teleport target.
transitionstring | false"akaza-dialog"Named Vue transition.
durationnumber100Transition duration in ms.
asstring"div"Root element tag.
uiDialogUiCSS class overrides.

Slots

SlotScoped propsDescription
trigger{ isOpen, open, close, toggle }Element that opens the dialog.
overlayBackdrop element.
header{ close, titleId }Header region.
titleDialog title. Defaults to the title prop.
descriptionDescription text. Defaults to the description prop.
body{ close, descriptionId }Main content area.
footer{ close }Action buttons region.

Exposed methods

MethodSignatureDescription
open(reason?, event?) => voidOpens the dialog.
close(reason?, event?) => voidCloses the dialog.
toggle(reason?, event?) => voidToggles the dialog.
titleIdstringAuto-generated id for the title element.
descriptionIdstringAuto-generated id for the description element.

Emits

EventPayloadDescription
open-change[open: boolean, details]Fired when the open state changes.

UI Options

KeyDescription
overlayThe backdrop overlay.
contentThe dialog panel.
headerThe header region.
titleThe title element.
descriptionThe description element.
bodyThe body region.
footerThe footer region.

Styling Hooks

UI keyCSS classData attrs
overlayakaza-dialog-overlaydata-akaza-state
contentakaza-dialog-contentdata-akaza-state, data-akaza-fullscreen
headerakaza-dialog-header
titleakaza-dialog-title
descriptionakaza-dialog-description
bodyakaza-dialog-body
footerakaza-dialog-footer

Dialog renders trigger slot content plus teleported overlay/content. Use ui keys instead of relying on plain class fallthrough.