Back to Base UIYou are on Dialog.

Dialog

A modal that tips into view from its edge while the page blurs behind it.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks

Libraries

Base UI

Motion

Spring + short tween

Reduced motion

Fade in place
dialog.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/dialog.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/dialog.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
dialog.tsx
"use client";

import * as React from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { X } from "lucide-react";
import { cn } from "@/lib/utils";

export type DialogProps = {
  trigger?: React.ReactNode;
  title?: string;
  description?: string;
  open?: boolean;
  defaultOpen?: boolean;
  onOpenChange?: (open: boolean) => void;
  children?: React.ReactNode;
  className?: string;
};

const popupSpring = { type: "spring", stiffness: 150, damping: 25 } as const;
const veil = { duration: 0.4, ease: [0.215, 0.61, 0.355, 1] } as const;

export function Dialog({
  trigger = "Open dialog",
  title = "Edit profile",
  description = "Make changes to your profile here.",
  open,
  defaultOpen = false,
  onOpenChange,
  children,
  className,
}: DialogProps) {
  const [internal, setInternal] = React.useState(defaultOpen);
  const value = open ?? internal;
  const reduce = useReducedMotion();
  const titleId = React.useId();
  const descriptionId = React.useId();

  const setOpen = (next: boolean) => {
    if (open === undefined) setInternal(next);
    onOpenChange?.(next);
  };

  React.useEffect(() => {
    if (!value) return;
    const onKey = (event: KeyboardEvent) => {
      if (event.key === "Escape") setOpen(false);
    };
    document.addEventListener("keydown", onKey);
    return () => document.removeEventListener("keydown", onKey);
  });

  return (
    <>
      <button
        type="button"
        onClick={() => setOpen(true)}
        className="inline-flex h-8 items-center rounded-md bg-foreground px-3 text-[13px] font-medium text-background"
      >
        {trigger}
      </button>
      <AnimatePresence>
        {value && (
          <div className="fixed inset-0 z-50 flex items-center justify-center p-4">
            <motion.button
              type="button"
              aria-label="Close dialog"
              initial={{ opacity: 0 }}
              animate={{ opacity: 1 }}
              exit={{ opacity: 0 }}
              transition={veil}
              onClick={() => setOpen(false)}
              className="absolute inset-0 bg-background/60 backdrop-blur-sm"
            />
            <motion.div
              role="dialog"
              aria-modal="true"
              aria-labelledby={titleId}
              aria-describedby={descriptionId}
              initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.96, y: 8, filter: "blur(4px)" }}
              animate={reduce ? { opacity: 1 } : { opacity: 1, scale: 1, y: 0, filter: "blur(0px)" }}
              exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.97, y: 4, filter: "blur(2px)" }}
              transition={reduce ? { duration: 0.2 } : popupSpring}
              className={cn("relative w-full max-w-sm rounded-xl border bg-background p-5 shadow-2xl", className)}
            >
              <button
                type="button"
                aria-label="Close"
                onClick={() => setOpen(false)}
                className="absolute right-3 top-3 rounded-md p-1 text-muted-foreground hover:bg-accent"
              >
                <X className="size-4" />
              </button>
              <h2 id={titleId} className="text-[15px] font-medium">{title}</h2>
              <p id={descriptionId} className="mt-1.5 text-[13px] leading-6 text-muted-foreground">{description}</p>
              {children}
              <div className="mt-5 flex justify-end gap-2">
                <button type="button" onClick={() => setOpen(false)} className="h-8 rounded-md border px-3 text-[13px]">
                  Cancel
                </button>
                <button type="button" onClick={() => setOpen(false)} className="h-8 rounded-md bg-foreground px-3 text-[13px] font-medium text-background">
                  Save
                </button>
              </div>
            </motion.div>
          </div>
        )}
      </AnimatePresence>
    </>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/dialog.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

dialog.tsx
import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogTitle,
  DialogDescription,
  DialogFooter,
  DialogClose,
} from "@/components/prequelui/dialog";
import { Button } from "@/components/ui/button";

export default function Demo() {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button>Open dialog</Button>
      </DialogTrigger>
      <DialogContent side="top">
        <DialogTitle>Invite a teammate</DialogTitle>
        <DialogDescription>
          They will receive an email with a link to join this workspace.
        </DialogDescription>
        <DialogFooter>
          <DialogClose asChild>
            <Button variant="ghost">Cancel</Button>
          </DialogClose>
          <Button>Send invite</Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}
import { Dialog } from "@/components/prequelui/dialog";

export function Variant() {
  return (
    <Dialog tempo={1.2}>
      …
    </Dialog>
  );
}
03

Animation

The popup behaves like a card standing on the page: it tips from the edge it belongs to while the veil both tints and blurs the page behind it. The veil animates colour and filter together, never opacity alone.

  • Popup spring: stiffness 150, damping 25.
  • Entry: perspective 500 px, 20° tilt, scale 0.8, 4 px blur.
  • Exit: 200 ms away-ease, faster than the entrance and without the tilt.
  • Reopening mid-close starts from the current colour and blur.
  • Reduced motion removes the 3D tilt and the blur, keeping the fade.
spring 150 / 25rotateX 20°scale 0.8overlay 400 ms
04

API Reference

Every part takes exactly the props of the Dialog primitive. The animated surface adds only motion props, so the accessibility tree and keyboard behaviour stay the same.

Dialog

PropTypeDefault
openboolean—
defaultOpenbooleanfalse
onOpenChange(open: boolean) => void—
modalbooleantrue
side"top" | "bottom" | "left" | "right""top"

DialogContent

PropTypeDefault
side"top" | "bottom" | "left" | "right"inherited
showClosebooleantrue
hideOverlaybooleanfalse
transitionTransitioncomponent spring or tween
exitTransitionTransition200 ms, away ease
classNamestring—

DialogTrigger / DialogClose

PropTypeDefault
asChildbooleanfalse
classNamestring—

Next component

Drawer

A panel that snaps in from an edge and leaves faster than it arrived.