MorphIsland
A pill that morphs between states: width lands first, height a beat later, content swaps with a blur. Effects.
Open playgroundAbout
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
npm i @ashutoshswamy/smouiUsage
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.
numberdefault2.8- onChange
Called when a click steps to a new state.
(id: string) => void
More effects components
- AuroraSlow drifting colour behind your content. Only transforms animate; it stands still with reduced motion.
- BorderBeamA light that runs around the edge of whatever it wraps, at an even pace along straight sides and rounded corners alike. Reduced motion parks it still.
- CompareSliderBefore/after reveal. Drag the divider; the top layer follows on a spring. It sweeps once to show it moves.
- ConfettiButton that throws flat confetti on press. Pieces fly out, tumble, then fall and fade.
- DotFieldA grid of dots that swells and shrinks away from the pointer, then springs home. One canvas, asleep when nothing moves.
- GlassLensA magnifier that drifts after the cursor like a drop of water. Press to zoom further.