Skip to content

Dialog

Open a modal panel while keeping keyboard focus inside it.

Demos

Width

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy Dialog.vue and index.ts into app/components/ui/dialog/.

API

Variants and defaults

PropValuesDefault
widthxs, sm, md, lg, xlmd

width sets the floating surface width, independently of control size. The surface stays inside the viewport.

Props

PropTypeDefaultDescription
titlestring—Convenience title. Slot #title takes priority.
descriptionstring—Convenience description. Slot #description takes priority.
ariaLabelstring—Fallback 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.
uiDialogUi—CSS class overrides.

Slots

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

Events

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

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.

Keyboard

KeyBehavior
Tab / Shift + TabCycles through focusable controls inside open dialog.
EscapeCloses topmost dialog and restores prior focus.

Opening moves focus inside, locks page scroll, and makes background content inert while modal is active.