Modals
VdModal renders a viewport-safe overlay dialog sized by the Fibonacci ladder and landscape Golden Ratio (1.618:1) by default. Drive it from a boolean with v-model:open, choose one of five size tiers (sm through 2xl), or add glass for a frosted panel. Tabbed bodies keep a steady height without jumping, and closing triggers an immediate smooth Fibonacci fade-out.
Modal Sizes
Glass Modal
Pass :glass="true" for a frosted panel and blurred backdrop (.vd-modal-glass). Open the live Glass Studio below and pull any slider while the modal is open — every --vd-glass-* token updates immediately in real time.
blur 16pxsaturate 2.05opacity 0.32border 0.36
Static Backdrop
Pass :close-on-backdrop="false" so a backdrop click does not dismiss a destructive confirmation.
CSS Variables
| Variable | Default | Description |
|---|---|---|
--vd-modal-bg | var(--vd-color-white) | Panel background |
--vd-modal-backdrop-bg | rgba(0,0,0,0.5) | Backdrop overlay color |
--vd-modal-border-color | var(--vd-border-color) | Panel border color |
--vd-modal-padding | 1.3125rem (21px) | Panel padding (Fibonacci) |
--vd-modal-header-padding | 1.3125rem | Header padding |
--vd-modal-body-padding | 1.3125rem | Body padding |
--vd-modal-footer-padding | 1.3125rem | Footer padding |
--vd-modal-golden-ratio | 1.618034 | Default landscape proportion ratio |
--vd-modal-max-height | min(95dvh, calc(100dvh - 2*margin)) | Viewport-safe maximum height |
--vd-modal-width-sm | 377px | Small width (fib 14, golden 233px tall) |
--vd-modal-width | 610px | Default width (fib 15, golden 377px tall) |
--vd-modal-width-lg | 987px | Large width (fib 16, golden 610px tall) |
--vd-modal-width-xl | 1280px | Extra-large wide workspace width |
--vd-modal-width-2xl | min(95dvw, 95dvh × φ) | 95% viewport-bounded golden width |
--vd-modal-enter-duration | 233ms (--vd-duration-233) | Enter timing |
--vd-modal-leave-duration | 144ms (--vd-duration-144) | Smooth exit timing |
--vd-modal-z-index | 1050 | Modal stacking |
--vd-modal-backdrop-z-index | 1040 | Backdrop stacking |
--vd-glass-blur | 16px | Glass modal blur (backdrop uses 55%) |
--vd-glass-saturate | 2.05 | Glass backdrop-filter saturation |
--vd-glass-bg-opacity | 0.42 (0.18 dark) | Glass modal panel fill opacity |
--vd-glass-border-alpha | 0.4 (0.34 dark) | Glass modal panel border alpha |
--vd-glass-shadow | 0 14px 40px … | Glass panel box-shadow |
API Reference
Usage
<script setup lang="ts">
import { ref } from "vue";
import { VdModal } from "@vanduo-oss/vd3";
const open = ref(false);
</script>
<template>
<button class="vd-btn vd-btn-primary" @click="open = true">Open Modal</button>
<VdModal v-model:open="open" title="Modal Title" size="md">
<p class="vd-mb-0">Modal content goes here.</p>
<template #footer>
<button class="vd-btn vd-btn-outline" @click="open = false">
Cancel
</button>
<button class="vd-btn vd-btn-primary" @click="open = false">Save</button>
</template>
</VdModal>
</template>Props
| Prop | Description |
|---|---|
open | boolean (required) — controls visibility. Pair with v-model:open or handle @update:open. |
title | string — header title; also used as the dialog aria-label (falls back to "Dialog"). |
size | "sm" | "md" | "lg" | "xl" | "2xl" — landscape Fibonacci width tier (default "md"; "2xl" fills 95% of viewport in golden ratio). |
golden | boolean — maintain a 1.618:1 landscape Golden Ratio minimum proportion clamped to the viewport (default true). |
stableHeight | boolean — keep panel height steady when switching tabs so dialogs do not jump (default true). |
closeOnBackdrop | boolean — whether a backdrop click closes the modal (default true). |
glass | boolean — frosted glass panel + backdrop (`.vd-modal-glass` / `.vd-modal-glass-backdrop`, default false). |
animated | boolean — enable smooth Fibonacci scale & fade transition (233ms enter, 144ms fade-out; default true). |
duration | number — optional transition duration override in milliseconds. |
Events
| Event | Description |
|---|---|
update:open | Emitted with false when the modal requests to close (backdrop, Escape, or the close button). Enables v-model:open. |
close | Emitted alongside update:open whenever the modal closes. |
Slots
| Slot | Description |
|---|---|
header | Optional extra header content, rendered after the title. |
default | The modal body content. |
footer | Footer action bar — rendered only when provided. |
CSS Classes
| Class | Description |
|---|---|
.vd-modal | Root overlay container (present only while the modal is open). |
.vd-modal-open | Marks the overlay as open — drives the visible state. |
.vd-modal-backdrop | Full-screen backdrop; a click closes the modal unless close-on-backdrop is false. |
.vd-modal-panel | The centered dialog panel holding the header, scrollable body, and pinned footer. |
.vd-modal-panel-sm / -md / -lg / -xl / -2xl | Panel width & golden ratio sizing matching the size prop. |
.vd-modal-auto-height | Opt-out modifier added when :golden="false" (lets short modals shrink to content). |
.vd-modal-dynamic-height | Opt-out modifier added when :stable-height="false" (lets tab switches resize height). |
.vd-modal-glass | Root modifier for the frosted glass panel (set via the glass prop). |
.vd-modal-glass-backdrop | Backdrop blur companion to `.vd-modal-glass` (set via the glass prop). |
.vd-modal-header | Header bar with the title and the auto-rendered close button. |
.vd-modal-title | Heading element populated from the title prop. |
.vd-modal-body | Scrollable body region (the default slot). |
.vd-modal-footer | Pinned footer action bar (the footer slot). |
Accessibility
- The overlay is a
role="dialog"witharia-modal="true"; its accessible name comes from thetitleprop (falling back to "Dialog"). - On open, focus moves to the dialog panel so keyboard users start inside the modal.
- Escape closes the modal (emitting
update:openandclose). - A backdrop click closes the modal unless
:close-on-backdrop="false". - The auto-rendered close button carries
aria-label="Close".