On this page

Dialog

Live examples of Dialog, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz. Click a button, or Tab to it and press Enter.

A short form

Two fields and two buttons. Cancel comes first, the primary action last on the right (D10). The form submits on Enter.

DialogEditConnection.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Button } from '@/components/ui/button'
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'

// A short form in a dialog. Cancel comes before Save; Save is last, on the right (D10).
const open = ref(false)
const name = ref('Online store – EU')
const url = ref('https://shop.example.com')

function save() {
  open.value = false
}
</script>

<template>
  <Dialog v-model:open="open">
    <DialogTrigger as-child>
      <Button variant="outline">Edit connection</Button>
    </DialogTrigger>
    <DialogContent>
      <form class="contents" @submit.prevent="save">
        <DialogHeader>
          <DialogTitle>Edit connection</DialogTitle>
          <DialogDescription>Changes apply from the next sync. Orders already synced keep their store name.</DialogDescription>
        </DialogHeader>
        <div class="grid gap-(--bh-space-200)">
          <div class="grid gap-(--bh-space-050)">
            <Label for="connection-name">Name</Label>
            <Input id="connection-name" v-model="name" autocomplete="off" />
          </div>
          <div class="grid gap-(--bh-space-050)">
            <Label for="connection-url">Store address</Label>
            <Input id="connection-url" v-model="url" type="url" autocomplete="off" />
          </div>
        </div>
        <DialogFooter>
          <DialogClose as-child>
            <Button variant="outline">Cancel</Button>
          </DialogClose>
          <Button type="submit">Save changes</Button>
        </DialogFooter>
      </form>
    </DialogContent>
  </Dialog>
</template>

Information only

Nothing to save, so the footer has one Close button (show-close-button). Read-only values are text, not input boxes.

DialogDetails.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'

// Information only, so the footer has one Close button. Read-only values are text, not boxes.
const webhook = [
  { label: 'Event', value: 'order.created' },
  { label: 'Endpoint', value: 'https://erp.example.com/hooks/orders' },
  { label: 'Last delivery', value: '12 Nov 2026, 10:42 · 200 OK' },
]
</script>

<template>
  <Dialog>
    <DialogTrigger as-child>
      <Button variant="outline">View webhook</Button>
    </DialogTrigger>
    <DialogContent>
      <DialogHeader>
        <DialogTitle>Order webhook</DialogTitle>
        <DialogDescription>The online store calls this address when a new order is placed.</DialogDescription>
      </DialogHeader>
      <dl class="m-0 grid gap-(--bh-space-150) [&_dd]:m-0">
        <div v-for="row in webhook" :key="row.label" class="grid gap-(--bh-space-025)">
          <dt class="text-(--bh-color-text-subtle) [font:var(--bh-font-label-small)]">{{ row.label }}</dt>
          <dd class="break-all text-(--bh-color-text) [font:var(--bh-font-code-default)]">{{ row.value }}</dd>
        </div>
      </dl>
      <DialogFooter show-close-button />
    </DialogContent>
  </Dialog>
</template>

Long content

DialogScrollContent: when the dialog is taller than the window, the whole dialog scrolls inside the scrim, so the header and footer are never cut off.

DialogLongContent.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { Dialog, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogScrollContent, DialogTitle, DialogTrigger } from '@/components/ui/dialog'

// Content that can be taller than the screen: the scrim scrolls the whole dialog, header and footer included.
const sections = [
  { title: 'What we process', text: 'Order, customer and product records that the online store and the ERP exchange during a sync.' },
  { title: 'Why we process it', text: 'Only to copy those records between the two systems you connected, on the schedule you set.' },
  { title: 'Where it is kept', text: 'Records pass through the sync service and are not stored after a run, except the log of each run.' },
  { title: 'How long logs are kept', text: 'Sync logs are kept for 30 days so you can retry a failed run, then deleted.' },
  { title: 'Who can see it', text: 'People in your workspace with the Admin or Operator role, and support staff you invite to a ticket.' },
  { title: 'Ending the agreement', text: 'Disconnecting both systems stops processing at once. Logs are deleted within 30 days.' },
]
</script>

<template>
  <Dialog>
    <DialogTrigger as-child>
      <Button variant="outline">Read the agreement</Button>
    </DialogTrigger>
    <DialogScrollContent>
      <DialogHeader>
        <DialogTitle>Data processing agreement</DialogTitle>
        <DialogDescription>Read it before you connect the ERP. You can find it later under Settings › Legal.</DialogDescription>
      </DialogHeader>
      <section v-for="section in sections" :key="section.title" class="grid gap-(--bh-space-050)">
        <h3 class="m-0 text-(--bh-color-text) [font:var(--bh-font-heading-xsmall)]">{{ section.title }}</h3>
        <p class="m-0 text-(--bh-color-text-subtle)">{{ section.text }}</p>
      </section>
      <DialogFooter>
        <DialogClose as-child>
          <Button variant="outline">Not now</Button>
        </DialogClose>
        <DialogClose as-child>
          <Button>I agree</Button>
        </DialogClose>
      </DialogFooter>
    </DialogScrollContent>
  </Dialog>
</template>