Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

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

PropTypeDefaultWhat it does
state—Controlled activity shown in the island.
defaultState"timer"Starting activity when uncontrolled.
onStateChange—Called when the island changes activity (stop, decline, or a cycle step).
timerSeconds300Length of the countdown in seconds. It really ticks.
accent"#ff9f0a"Accent colour for the timer and the music bars.
cycle0Uncontrolled only: step through states every this many ms. 0 stays put.
states["timer", "music", "call"]Activities visited by cycle and autoplay.
track{ title: "Midnight Drive", artist: "Harbor Lights" }Track shown in the music activity.
caller"Ava Lin"Name shown in the call activity.
autoplayfalseUncontrolled only: morphs through the activities and opens each one until someone touches it.
className—Classes for the outer wrapper.
enableSoundtruePlays 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. 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 creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 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:

    1. Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with nxs_ and is shown only once.
    2. In your project root, next to package.json, create a file named .env.local with this line, using your own key:
      NEXUS_API_KEY=nxs_your_key_here
    3. Open components.json and 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}"
          }
        }
      }

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.

Guides