driftkit
ComponentsDialog

Dialog

Motion-first modal dialog with backdrop blur, focus trap, keyboard support, and spring physics. Includes DialogTitle, DialogDescription, and DialogFooter sub-components.

Overlay

Installation

Copy and paste

Copy the component source code and paste it into your project.

import { Dialog, DialogTitle, DialogDescription, DialogFooter } from "driftkit";

Props

NameTypeRequiredDescription
openbooleanYesControls dialog visibility. Use state to manage open/close.
onClose() => voidYesCallback when dialog should close (backdrop click, Escape key).
size"sm" | "md" | "lg"NoDialog width. Small (24rem), medium (32rem), large (42rem).
titlestringNoAccessible title for screen readers via aria-label.
childrenReactNodeYesDialog content - typically DialogTitle, DialogDescription, and DialogFooter.
🎮

Playground

Tune spring physics for this component

Live Preview

Cancel
Confirm

Spring Physics

300
30
1

Generated Code

const springConfig = {
  "type": "spring",
  "stiffness": 300,
  "damping": 30,
  "mass": 1
};

// Basic hover animation
<motion.div
  whileHover={{ scale: 1.05 }}
  whileTap={{ scale: 0.95 }}
  transition={springConfig}
>
  <Dialog />
</motion.div>

// Advanced with custom animations
<motion.div
  animate={{ 
    scale: [1, 1.02, 1],
    y: [0, -4, 0]
  }}
  transition={{
    ...springConfig,
    repeat: Infinity,
    repeatDelay: 2
  }}
>
  <Dialog />
</motion.div>
Stiffness: Controls animation speed. Higher values create snappier animations.
Damping: Controls resistance to motion. Lower values create more bounce and overshoot.
Mass: Controls the perceived weight. Higher values make animations slower with more momentum.

Source Code

View the source code on GitHub to see the full implementation.

View on GitHub