Morphiq

Components / Animations / Liquid Transition

Liquid Transition

Content changes behind a fluid front. No-slip walls make the middle of the front lead the edges by a Poiseuille parabola that grows with speed, and the edge rings under tension by the damped wave equation, ∂²h/∂t² = (σ/μ)·∂²h/∂x² − γ·∂h/∂t, plucked by the sweep’s own acceleration. So the wobble quickens as √σ and a wider box sloshes slower. The new content goes in at full cover; droplets trail the drain.

Usage

import LiquidTransition from '@/components/liquid-transition'

<LiquidTransition transitionKey={route}>
  {page}
</LiquidTransition>

Installation

npx shadcn@latest add https://morphiq.prathampatel.design/r/liquid-transition.json

Model

∂²h/∂t² = (σ/μ)·∂²h/∂x² − γ·∂h/∂t

the edge ringing under tension, free at both walls

Props

PropertyTypeDefaultDescription
transitionKeystring | number—Changing this starts a transition. The new children are swapped in at full cover. Changed again mid-sweep, the fluid carries on or turns back from where it is and swaps in whatever is newest; changed back to the key still on show, it backs out.
direction'up' | 'down' | 'left' | 'right''up'The way the front travels.
colorstring'#e8e4dc'The fluid's colour. Any CSS colour.
durationnumber1100Cover and drain together, ms. Held to at least 200; anything that is not a finite number falls back to 1100.
tensionnumber1Surface tension. The edge's wobble frequency goes as its square root.
leadnumber1How far the middle of the front outruns the walls. 0 is a flat front.
dropletsnumber1How many droplets break off the draining edge, to a length of it: a wider edge sheds more. 0 for none.
onCovered() => void—Called at full cover, as the content swaps. Not called for a sweep that backs out without swapping.
onComplete() => void—Called once the fluid has gone and the last droplet has dried.
childrenReactNode—What is showing for the current transitionKey. New children go in at full cover.