MorphIsland

A pill that morphs between states: width lands first, height a beat later, content swaps with a blur. Effects.

Open playground

About

MorphIsland is a React component in the Effects category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { MorphIsland } from "@ashutoshswamy/smoui" and set states, value, interval among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { MorphIsland } from "@ashutoshswamy/smoui";

<MorphIsland
  states={[
    { id: "idle", width: 150, height: 40, children: <span>Now playing</span> },
    { id: "track", width: 300, height: 84, children: <Track /> },
  ]}
/>

Props 4

states

Each state's size and content.

{ id: string; width: number; height: number; children: ReactNode }[]
value

Controlled active id.

string
interval

Seconds between automatic steps. 0 turns autoplay off. Clicking stops it and steps.

numberdefault 2.8
onChange

Called when a click steps to a new state.

(id: string) => void