Dialog

A window overlaid on the primary content. Plays open and close sounds.

A window overlaid on the primary content. The sensory-ui Dialog plays sounds when opening and closing, signaling the modal transition.

Pattern: Open / close

Demo

Live demoSwitch sound packs to compare

Installation

npx shadcn@latest add SatyamVyas04/sensory-ui/sensory-ui-dialog

Import

import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogOverlay,
  DialogPortal,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/sensory-ui/dialog";

Sound Props

PropTypeDefaultDescription
soundSoundRole | false"overlay.open"Sound played when the dialog opens.
closeSoundSoundRole | false"overlay.close"Sound played when the dialog closes.
volumenumber1Per-component volume multiplier (0–1).

Default Sound Role

overlay.open on open, overlay.close on close.

Usage

<Dialog>
  <DialogTrigger>Open</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Edit profile</DialogTitle>
      <DialogDescription>
        Make changes to your profile here.
      </DialogDescription>
    </DialogHeader>
  </DialogContent>
</Dialog>

Custom sounds

<Dialog sound="notification.info" closeSound="interaction.subtle">
  {/* ... */}
</Dialog>

Disable sounds

<Dialog sound={false} closeSound={false}>
  {/* ... */}
</Dialog>

Customizations

Form dialog

<Dialog sound="overlay.open" closeSound="overlay.close">
  <DialogTrigger>Edit profile</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Edit profile</DialogTitle>
    </DialogHeader>
    {/* Form fields */}
  </DialogContent>
</Dialog>

Confirmation dialog

<Dialog sound="notification.warning" closeSound="overlay.close">
  <DialogTrigger>Delete item</DialogTrigger>
  <DialogContent>
    {/* Warning content */}
  </DialogContent>
</Dialog>

Default Props

PropValue
sound"overlay.open"
closeSound"overlay.close"
volume1

Tasteful Sound Choices

SituationRecommended SoundWhy
Form dialogoverlay.open / overlay.closeDefault: clear modal cue
Confirmationnotification.warningWarns of important decision
Info modalnotification.infoNeutral, informative
Image lightboxoverlay.open / overlay.closeContent focus
Silent modalfalseFor auto-opening dialogs

When to Use

  • Form editing: Profile, settings, create/edit forms
  • Confirmations: Destructive action confirmations
  • Details: Expanded item details
  • Lightboxes: Image or media viewers

Avoid sound on

  • Dialogs that open automatically on page load
  • Dialogs triggered by non-user actions

Event Triggers

EventDefault Sound
Dialog opensoverlay.open
Dialog closesoverlay.close

shadcn/ui Reference

View the original Dialog documentation.