Animated File Upload
smoothui-registry/animated-file-uploadFreeComponent
Animated drag-and-drop file upload component
Install it
npx shadcn@latest add https://www.smoothui.dev/r/animated-file-upload.jsonSource
1"use client";23import { cn } from "@/lib/utils";4import { AnimatePresence, motion, useReducedMotion } from "motion/react";5import { useCallback, useRef, useState } from "react";67export interface AnimatedFileUploadProps {8 accept?: string;9 className?: string;10 disabled?: boolean;11 maxSize?: number;12 multiple?: boolean;13 onFilesSelected: (files: File[]) => void;14}1516/* ─────────────────────────────────────────────────────────17 * ANIMATION STORYBOARD18 *19 * 0ms drop zone visible, dashed border idle20 * drag zone scales 1.02, border goes primary, icon floats up21 * drop icon bounces back, file rows slide in staggered22 * remove file row slides out right + fades23 * layout remaining files reorder with layout animation24 * ───────────────────────────────────────────────────────── */2526const SPRING = {27 bounce: 0.1,28 duration: 0.25,29 type: "spring" as const,30};3132const SPRING_BOUNCY = {33 bounce: 0.2,34 duration: 0.3,35 type: "spring" as const,36};3738function formatFileSize(bytes: number): string {39 if (bytes < 1024) {40 return `${bytes} B`;41 }42 if (bytes < 1024 * 1024) {43 return `${(bytes / 1024).toFixed(1)} KB`;44 }45 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;46}4748function FileIcon() {49 return (50 <svg51 aria-hidden="true"52 className="h-4 w-4 text-muted-foreground"53 fill="none"54 stroke="currentColor"55 strokeWidth={1.5}56 viewBox="0 0 24 24"57 >58 <path59 d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"60 strokeLinecap="round"61 strokeLinejoin="round"62 />63 </svg>64 );65}6667function UploadIcon({ isDragOver }: { isDragOver: boolean }) {68 const shouldReduceMotion = useReducedMotion();6970 return (71 <motion.div72 animate={73 shouldReduceMotion74 ? undefined75 : isDragOver76 ? { scale: 1.15, y: -4 }77 : { scale: 1, y: 0 }78 }79 transition={shouldReduceMotion ? { duration: 0 } : SPRING_BOUNCY}80 >81 <svg82 aria-hidden="true"83 className={cn(84// … truncated
What it pulls in
npm packages
Files it writes
More from SmoothUI Registry
All 178 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Agent Avataragent-avatar | SmoothUI Registry | Components | Free | no deps | |
| Ai Approvalai-approval | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Artifactai-artifact | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Branchai-branch | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Citationai-citation | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Context Meterai-context-meter | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Conversationai-conversation | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Coreai-core | SmoothUI Registry | Components | Free | 1 dep |
