# Dialog

> A modal panel with a title, description, body and free-form footer — portals out, traps focus, and locks the page's scroll while open.

- Package: `fancy-ui-vue` (Vue 3.5+ + Tailwind CSS v4)
- Category: Overlays
- Tags: modal, dialog, overlay, portal, focus-trap
- Types: `DialogProps`
- Docs: https://fancy-ui.rama.app/docs/components/dialog
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/vue/src/components/dialog

## Import

```vue
<script setup lang="ts">
import { Dialog } from 'fancy-ui-vue';
</script>
```

Setup (once per project): `npm install fancy-ui-vue`, then put these lines in your main CSS file (the stylesheet imports go right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-vue/tailwind.css";
@import "fancy-ui-vue/styles.css";
```

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model:open` (Svelte `open`) | `boolean` | `false` | Whether the dialog is open; bindable |
| `@open-change` (Svelte `onOpenChange`) | `(open: boolean) => void` | — | Fires whenever open changes, from any trigger |
| `title` | `string` | — | The heading. Omitted entirely (not just visually) when not given |
| `description` | `string` | — | The copy under the title. Same omission rule as title |
| `dismissible` | `boolean` | `true` | Whether Escape and an outside click close the dialog; the close button always works |
| `initialFocus` | `HTMLElement \| null` | — | Element to focus once the dialog opens; defaults to the first focusable descendant |
| `class` | `string` | — | Additional CSS classes for the panel |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the panel element |
| `sound` | `boolean` | `false` | Plays open when the trigger opens the dialog and close on every dismissal, once the user has enabled sound |

## Slots

| Slot | Description |
| --- | --- |
| `#default` (Svelte `children`) | The dialog's body |
| `#footer` (Svelte `footer`) | The action row under the body — free-form, callers build their own buttons |
| `#trigger` (Svelte `trigger`) | Optional trigger; renders in place and opens the dialog on activation |

## Example

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Button, Dialog } from "fancy-ui-vue";

const open = ref(false);
const email = ref("");
</script>

<template>
	<Dialog
		v-model:open="open"
		title="Invite a member"
		description="Send an email invite to join the workspace."
	>
		<template #trigger>
			<Button>Invite member</Button>
		</template>

		<input
			v-model="email"
			type="email"
			placeholder="email@example.com"
			aria-label="Email address"
			class="border-input bg-background w-full rounded-lg border px-3 py-2 text-sm"
		/>

		<template #footer>
			<Button variant="outline" :onclick="() => (open = false)">Cancel</Button>
			<Button :onclick="() => (open = false)">Invite</Button>
		</template>
	</Dialog>
</template>
```
