Dynamic Island, animated React component
A black pill that grows into whatever is happening: a running timer, the song that is playing or an incoming call. Each change stretches it, the width shooting out first and the height catching up on a looser spring, and tapping it opens live controls.
- Pro
- Cards
- Spring
Pops when the pill opens, pops quieter when it tucks away and whooshes when you stop the timer or decline the call. Sound is off on this site until you switch it on.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| state | "idle" | "timer" | "music" | "call" | — | Controlled activity shown in the island. |
| defaultState | "idle" | "timer" | "music" | "call" | "timer" | Starting activity when uncontrolled. |
| onStateChange | (state: IslandState) => void | — | Called when the island changes activity (stop, decline, or a cycle step). |
| timerSeconds | number | 300 | Length of the countdown in seconds. It really ticks. |
| accent | string | "#ff9f0a" | Accent colour for the timer and the music bars. |
| cycle | number | 0 | Uncontrolled only: step through states every this many ms. 0 stays put. |
| states | IslandState[] | ["timer", "music", "call"] | Activities visited by cycle and autoplay. |
| track | { title: string; artist: string } | { title: "Midnight Drive", artist: "Harbor Lights" } | Track shown in the music activity. |
| caller | string | "Ava Lin" | Name shown in the call activity. |
| autoplay | boolean | false | Uncontrolled only: morphs through the activities and opens each one until someone touches it. |
| className | string | — | Classes for the outer wrapper. |
| enableSound | boolean | true | Plays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry with your API key
Dynamic Island is a Pro item, so the CLI has to send your API key. Do this once per project:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand add this entry inside the outermost braces, next to"aliases". Leave{name}and${NEXUS_API_KEY}exactly as written; the CLI fills them in:"registries": { "@nexus-labs": { "url": "https://www.nexus-ui.com/api/registry/{name}", "headers": { "Authorization": "Bearer ${NEXUS_API_KEY}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
How Dynamic Island works
A black pill that grows into whatever is happening: a running timer, the song that is playing, an incoming call. Every change stretches it: the width shoots out first and the height catches up on a looser spring, so the tap again or press Escape to tuck it away.
The source, the install command and the build prompt come with Pro.
Dynamic Island questions
How do I install the Dynamic Island component?
Run `npx shadcn@latest add @nexus-labs/dynamic-island`. It installs framer-motion, and the component is a client component ("use client"). It is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).
How do I control which activity the island shows?
Pass `state` ("idle", "timer", "music" or "call") with `onStateChange` to control it yourself, or use `defaultState` (default "timer") to let it manage itself. `cycle` steps through `states` every N ms when uncontrolled, and `autoplay` morphs through them and opens each one.
What can I customize in the timer, music and call views?
`timerSeconds` sets the countdown length (default 300) and it really ticks, `accent` sets the timer and music-bar color (default `#ff9f0a`), `track` takes `{ title, artist }`, and `caller` sets the name in the call view (default "Ava Lin").
How is the morph animated, and is it keyboard accessible?
It is a Framer Motion div whose width and height animate on separate springs, the width faster than the height, so the pill squashes into each new shape. The compact pill is a button with an `aria-label`, Escape or a tap outside closes the expanded controls, and with reduced motion the size changes are instant.
Does it make sound, and how do I turn it off?
Pops when the pill opens, pops quieter when it tucks away and whooshes when you stop the timer or decline the call. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.