Components

Crystal Modal

A glassmorphism modal dialog for React built on Radix Dialog, Motion and Tailwind CSS. The pane scales up out of a blur while the page behind it frosts over — and focus trapping, Escape to close, scroll lock and ARIA all come from Radix.

  • Radix Dialog
  • Enter & exit animations
  • Frosted overlay
  • Focus trap
  • prefers-reduced-motion

Installation

$ npx shadcn@latest add https://duskui.com/r/crystal-modal.json

Usage

invite-dialog.tsx
import {
  CrystalModal,
  CrystalModalContent,
  CrystalModalDescription,
  CrystalModalHeader,
  CrystalModalTitle,
  CrystalModalTrigger,
} from "@/components/dusk/glass/crystal-modal"
import { Button } from "@/components/ui/button"

export function InviteDialog() {
  return (
    <CrystalModal>
      <CrystalModalTrigger asChild>
        <Button>Invite</Button>
      </CrystalModalTrigger>
      <CrystalModalContent>
        <CrystalModalHeader>
          <CrystalModalTitle>Invite your team</CrystalModalTitle>
          <CrystalModalDescription>They'll get an email with a link.</CrystalModalDescription>
        </CrystalModalHeader>
      </CrystalModalContent>
    </CrystalModal>
  )
}

Examples

Controlled form

Control it with open and onOpenChange to close after an async save. The exit animation still plays. Fields here are Ice Inputs and the submit is a loading Frost Button.

API Reference

CrystalModal takes Radix Dialog Root props (open, defaultOpen, onOpenChange, modal). Trigger, Close, Title and Description are the Radix parts with styling. The props below are for CrystalModalContent, which also accepts Radix Content props such as onEscapeKeyDown and onOpenAutoFocus.

PropTypeDefaultDescription
size"sm" | "md" | "lg" | "xl""md"Max width of the pane.
showCloseButtonbooleantrueRender the × button in the corner.
overlayClassNamestring—Classes for the frosted overlay.
containerHTMLElement | nulldocument.bodyPortal container.

Accessibility

  • Built on Radix Dialog: focus is trapped inside and returned to the trigger on close, Escape closes, and the page behind is inert and scroll-locked.
  • Always include a CrystalModalTitle (it labels the dialog) and ideally a CrystalModalDescription.
  • The close button has an accessible name and a focus-visible ring.
  • Browsers without backdrop-filter get an opaque pane and a darker overlay, so contrast never depends on the blur.
  • With reduced motion the pane only fades — no scale, slide or blur.