Dynamic Island
godui/dynamic-islandFreeComponent
An Apple-inspired pill that springs between size presets while its content cross-fades.
Install it
npx shadcn@latest add https://godui.design/r/dynamic-island.jsonSource
1"use client";23import { AnimatePresence, motion, useReducedMotion } from "framer-motion";4import * as React from "react";56export type DynamicIslandSize =7 | "compact"8 | "default"9 | "long"10 | "tall"11 | "large";1213export type DynamicIslandProps = React.HTMLAttributes<HTMLDivElement> & {14 /** Shape preset the island morphs to. */15 size?: DynamicIslandSize;16 /**17 * Identity of the current content. Change it to cross-fade the inner view;18 * defaults to `size` so each shape transitions its content.19 */20 presenceKey?: React.Key;21};2223const SIZES: Record<24 DynamicIslandSize,25 { width: number; height: number; radius: number }26> = {27 compact: { width: 140, height: 36, radius: 18 },28 default: { width: 220, height: 44, radius: 22 },29 long: { width: 360, height: 52, radius: 26 },30 tall: { width: 260, height: 120, radius: 28 },31 large: { width: 360, height: 200, radius: 36 },32};3334// Underdamped so the shell settles with the signature rubbery overshoot.35const SHELL_SPRING = {36 type: "spring" as const,37 stiffness: 520,38 damping: 32,39};4041const DynamicIsland = React.forwardRef<HTMLDivElement, DynamicIslandProps>(42 (43 { size = "default", presenceKey, className, style, children, ...props },44 ref,45 ) => {46 const reduceMotion = useReducedMotion();47 const dims = SIZES[size];48 const key = presenceKey ?? size;4950 return (51 <motion.div52 ref={ref}53 data-slot="dynamic-island"54 layout55 initial={false}56 animate={{57 width: dims.width,58 height: dims.height,59 borderRadius: dims.radius,60 }}61 transition={reduceMotion ? { duration: 0 } : SHELL_SPRING}62 className={`relative flex items-center justify-center overflow-hidden bg-black text-white shadow-xl ${className ?? ""}`}63 style={{ maxWidth: "100%", ...style }}64 {...(props as React.ComponentProps<typeof motion.div>)}65 >66 <AnimatePresence mode="popLayout" initial={false}>67 <motion.div68 key={key}69 initial={70 reduceMotion71 ? false72 : { opacity: 0, scale: 0.9, filter: "blur(4px)" }73 }74 animate={{ opacity: 1, scale: 1, filter: "blur(0px)" }}75 exit={76 reduceMotion77 ? undefined78 : { opacity: 0, scale: 0.9, filter: "blur(4px)" }79 }80 transition={{ duration: 0.2, ease: "easeOut" }}81// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from godui
All 105 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | godui | Components | Free | 1 dep | |
| Agent Flowagent-flow | godui | Components | Free | 1 dep | |
| Agent Timelineagent-timeline | godui | Components | Free | 1 dep | |
| Animated Beamanimated-beam | godui | Components | Free | 1 dep | |
| Animated Testimonialsanimated-testimonials | godui | Components | Free | 1 dep | |
| Animated Tooltipanimated-tooltip | godui | Components | Free | 1 dep | |
| App Showcaseapp-showcase | godui | Components | Free | 1 dep | |
| Aurora Textaurora-text | godui | Components | Free | no deps |
