useChromeMorph

The shared morph hook for floating chrome — a toolbar pill, launcher, or nav dock. It animates a container's width/height/border-radius between its collapsed box and an open panel on a tuned curve, cross-fading rest↔panel, then shrinks cleanly back. Position-agnostic and reduced-motion aware.

Installation

npx shadcn@latest add @byronwade/use-chrome-morph

Props

PropTypeDefaultDescription
morphRefRefObject<HTMLDivElement | null>The morphing container; its CSS anchoring sets the grow direction (the hook only sizes).
openbooleanWhether a panel is currently open.
growHeightbooleanBloom width + height (panels) or width-only (menus that swap their own content).
width() => numberOpen width target in px, read at morph time.
restRefRefObject<HTMLDivElement | null>Resting content faded out as the panel blooms in.
panelRefRefObject<HTMLDivElement | null>Active panel faded in and measured for the open height.
height() => numberExplicit open height; falls back to the panel's measured height.
collapsedFrom() => { w: number; h: number } | nullOverride the collapsed start/end box — e.g. bloom out of a sibling pill.
durationMsnumber220Bloom-down duration in ms.
depsReact.DependencyListExtra triggers that change the open target (which panel, its size…).