Communication
Dynamic island
A pill that morphs between compact live activities. Width, height and corner move together on a spring; content fades in once the shape settles.
Examples and variants
Activities
Switch between call, timer, music and upload.
function IslandActivities() {
const [activity, setActivity] = useState<"call" | "timer" | "music" | "upload">("music")
const [seconds, setSeconds] = useState(272)
useEffect(() => {
if (activity !== "timer") return
const t = window.setInterval(() => setSeconds((s) => Math.max(0, s - 1)), 1000)
return () => window.clearInterval(t)
}, [activity])
const content = {
call: (
<span className="flex items-center gap-3 text-sm">
<PhoneIcon className="size-(--size-icon-sm) text-(--color-success)" /> Alex · 02:14
</span>
),
timer: (
<span className="flex items-center gap-2 text-sm tabular-nums">
<TimerIcon className="size-(--size-icon-sm) text-(--color-warning)" />
{String(Math.floor(seconds / 60)).padStart(2, "0")}:{String(seconds % 60).padStart(2, "0")}
</span>
),
music: (
<span className="flex w-64 items-center gap-3 py-2">
<span className="flex size-10 items-center justify-center rounded-(--shape-full) bg-(--color-bg-selected)">
<MusicIcon className="size-(--size-icon-md)" />
</span>
<span className="flex-1">
<span className="block text-sm font-medium">Liquid Afternoon</span>
<span className="block text-caption opacity-70">Isotopi Radio</span>
</span>
<Spinner variant="wave" size="sm" label="Playing" />
</span>
),
upload: (
<span className="flex w-56 items-center gap-3 text-sm">
<UploadIcon className="size-(--size-icon-sm)" />
<Progress value={64} aria-label="Upload" className="flex-1" />
</span>
),
}[activity]
return (
<div className="flex flex-col items-center gap-4">
<DynamicIsland activity={activity}>{content}</DynamicIsland>
<div className="flex flex-wrap justify-center gap-2">
{(["call", "timer", "music", "upload"] as const).map((a) => (
<Button key={a} size="sm" variant={a === activity ? "primary" : "secondary"} onClick={() => setActivity(a)}>
{a}
</Button>
))}
</div>
</div>
)
}Spec drawing
Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.
Install
With the CLI
The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/dynamic-island.jsonBy hand
No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.
Install the packages it uses.
Terminalnpm install cnCopy this file to the same paths in your project. Imports use the
@/alias for your project root.components/ui/dynamic-island.tsxdynamic-island
components/ui/dynamic-island.tsx"use client" import * as React from "react" import { cn } from "cn" /* Dynamic island: a pill that morphs between compact live activities (a call, a timer, music, an upload). Width, height and corner move together on a spring; the new content fades in once the shape has settled. Pass a different `activity` key to morph. */ function DynamicIsland({ activity, children, label = "Live activity", className, }: { /** Changing this key morphs the island to the new content. */ activity: string children: React.ReactNode label?: string className?: string }) { const innerRef = React.useRef<HTMLDivElement>(null) const shellRef = React.useRef<HTMLDivElement>(null) React.useLayoutEffect(() => { const inner = innerRef.current const shell = shellRef.current if (!inner || !shell) return const fit = () => { shell.style.width = `${inner.offsetWidth}px` shell.style.height = `${inner.offsetHeight}px` } fit() const observer = new ResizeObserver(fit) observer.observe(inner) return () => observer.disconnect() }, [activity]) return ( <div ref={shellRef} role="status" aria-label={label} data-slot="dynamic-island" className={cn("dynamic-island relative overflow-hidden rounded-(--island-corner) bg-(--island-container) text-(--island-label) shadow-(--island-elevation)", className)} > <div ref={innerRef} key={activity} className="island-content absolute start-0 top-0 w-max px-(--island-padding-x) py-(--island-padding-y)"> {children} </div> </div> ) } export { DynamicIsland }
Imports
What the examples on this page import:
import {
import { ActivityStack, type Activity } from "@/components/ui/activity-stack"
import { Button } from "@/components/ui/button"
import { Dropzone } from "@/components/ui/dropzone"
import { DynamicIsland } from "@/components/ui/dynamic-island"
import { Progress } from "@/components/ui/progress"
import { RollingNumber } from "@/components/ui/rolling-number"
import { Spinner } from "@/components/ui/spinner"
import { Toggle } from "@/components/ui/toggle"
import { tokenMs } from "@/lib/motion/token-ms"Anatomy
- 1Shell · --island-container, --island-corner, --island-elevation.
- 2Content · --island-padding-*; any live content.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
activity | string | — | Changing the key morphs to the new content. |
children | ReactNode | — | The live content. |
label | string | "Live activity" | Accessible name. |
Tokens
Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.
| Token | Points to | Light | Dark |
|---|---|---|---|
--island-container | var(--surface-inverse) | oklch(0.22 0.01 260) | oklch(0.95 0 0) |
--island-label | var(--on-surface-inverse) | oklch(0.98 0.004 95) | oklch(0.14 0 0) |
--island-corner | var(--shape-full) | 999px | same |
--island-padding-x | var(--space-4) | 16px | same |
--island-padding-y | var(--space-2) | 8px | same |
--island-elevation | var(--elevation-3) | 0 1px 1px -0.5px oklch(0.22 0.01 260 / 8%), 0 3px 3px -1.5px oklch(0.22 0.01 260 / 8%), 0 6px 6px -3px oklch(0.22 0.01 260 / 8%), 0 12px 12px -6px oklch(0.22 0.01 260 / 8%), 0 24px 24px -12px oklch(0.22 0.01 260 / 8%), 0 48px 48px -24px oklch(0.22 0.01 260 / 6%) | 0 8px 20px oklch(0 0 0 / 45%), 0 20px 44px oklch(0 0 0 / 40%) |
Motion
| Trigger | What happens | Tokens |
|---|---|---|
| Activity change | Shape morphs on a bouncy spring; content fades in after. | --spring-bouncy, --duration-medium |
Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.
Accessibility
- role=status; keep text inside readable.
Usage
Do
- Use for one live, glanceable activity.
Don’t
- Don't put controls people must hunt for in it.
Code
"use client"
import * as React from "react"
import { cn } from "cn"
/*
Dynamic island: a pill that morphs between compact live activities (a
call, a timer, music, an upload). Width, height and corner move together
on a spring; the new content fades in once the shape has settled.
Pass a different `activity` key to morph.
*/
function DynamicIsland({
activity,
children,
label = "Live activity",
className,
}: {
/** Changing this key morphs the island to the new content. */
activity: string
children: React.ReactNode
label?: string
className?: string
}) {
const innerRef = React.useRef<HTMLDivElement>(null)
const shellRef = React.useRef<HTMLDivElement>(null)
React.useLayoutEffect(() => {
const inner = innerRef.current
const shell = shellRef.current
if (!inner || !shell) return
const fit = () => {
shell.style.width = `${inner.offsetWidth}px`
shell.style.height = `${inner.offsetHeight}px`
}
fit()
const observer = new ResizeObserver(fit)
observer.observe(inner)
return () => observer.disconnect()
}, [activity])
return (
<div
ref={shellRef}
role="status"
aria-label={label}
data-slot="dynamic-island"
className={cn("dynamic-island relative overflow-hidden rounded-(--island-corner) bg-(--island-container) text-(--island-label) shadow-(--island-elevation)", className)}
>
<div ref={innerRef} key={activity} className="island-content absolute start-0 top-0 w-max px-(--island-padding-x) py-(--island-padding-y)">
{children}
</div>
</div>
)
}
export { DynamicIsland }