{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "headless-dialog", "type": "registry:ui", "title": "Headless Dialog", "description": "A fully-managed, renderless dialog component jam-packed with accessibility and keyboard features, perfect for building completely custom dialogs and alerts.", "dependencies": [ "@headlessui/react", "motion" ], "files": [ { "path": "registry/headless/dialog/index.tsx", "content": "'use client';\n\nimport * as React from 'react';\nimport {\n Dialog as DialogPrimitive,\n DialogBackdrop as DialogBackdropPrimitive,\n DialogPanel as DialogPanelPrimitive,\n DialogTitle as DialogTitlePrimitive,\n Description as DialogDescriptionPrimitive,\n type DialogProps as DialogPrimitiveProps,\n type DialogBackdropProps as DialogBackdropPrimitiveProps,\n type DialogPanelProps as DialogPanelPrimitiveProps,\n type DialogTitleProps as DialogTitlePrimitiveProps,\n CloseButton,\n} from '@headlessui/react';\nimport {\n motion,\n AnimatePresence,\n type Transition,\n type HTMLMotionProps,\n} from 'motion/react';\n\nimport { cn } from '@/lib/utils';\nimport { X } from 'lucide-react';\n\ntype DialogProps = Omit<\n DialogPrimitiveProps,\n 'static'\n> & {\n className?: string;\n as?: TTag;\n};\n\nfunction Dialog({\n className,\n ...props\n}: DialogProps) {\n return (\n \n {props?.open && (\n \n )}\n \n );\n}\n\ntype DialogBackdropProps =\n DialogBackdropPrimitiveProps & {\n className?: string;\n as?: TTag;\n };\n\nfunction DialogBackdrop(\n props: DialogBackdropProps,\n) {\n const { className, as = motion.div, ...rest } = props;\n\n return (\n \n );\n}\n\ntype FlipDirection = 'top' | 'bottom' | 'left' | 'right';\n\ntype DialogPanelProps =\n Omit, 'transition'> &\n Omit, 'children'> & {\n from?: FlipDirection;\n transition?: Transition;\n as?: TTag;\n };\n\nfunction DialogPanel(\n props: DialogPanelProps,\n) {\n const {\n children,\n className,\n as = motion.div,\n from = 'top',\n transition = { type: 'spring', stiffness: 150, damping: 25 },\n ...rest\n } = props;\n\n const initialRotation =\n from === 'top' || from === 'left' ? '20deg' : '-20deg';\n const isVertical = from === 'top' || from === 'bottom';\n const rotateAxis = isVertical ? 'rotateX' : 'rotateY';\n\n return (\n \n {(bag) => (\n <>\n {typeof children === 'function' ? children(bag) : children}\n\n \n \n Close\n \n \n )}\n \n );\n}\n\ntype DialogHeaderProps =\n React.ComponentProps & {\n as?: TTag;\n };\n\nfunction DialogHeader({\n className,\n as: Component = 'div',\n ...props\n}: DialogHeaderProps) {\n return (\n \n );\n}\n\ntype DialogFooterProps =\n React.ComponentProps & {\n as?: TTag;\n };\n\nfunction DialogFooter({\n className,\n as: Component = 'div',\n ...props\n}: DialogFooterProps) {\n return (\n \n );\n}\n\ntype DialogTitleProps =\n DialogTitlePrimitiveProps & {\n className?: string;\n as?: TTag;\n };\n\nfunction DialogTitle({\n className,\n ...props\n}: DialogTitleProps) {\n return (\n \n );\n}\n\ntype DialogDescriptionProps =\n React.ComponentProps> & {\n className?: string;\n as?: TTag;\n };\n\nfunction DialogDescription({\n className,\n ...props\n}: DialogDescriptionProps) {\n return (\n \n );\n}\n\nexport {\n Dialog,\n DialogBackdrop,\n DialogPanel,\n DialogTitle,\n DialogDescription,\n DialogHeader,\n DialogFooter,\n type DialogProps,\n type DialogBackdropProps,\n type DialogPanelProps,\n type DialogTitleProps,\n type DialogDescriptionProps,\n type DialogHeaderProps,\n type DialogFooterProps,\n};\n", "type": "registry:ui", "target": "components/animate-ui/headless/dialog.tsx" } ] }