Morphiq

Components / Text Animations / Elastic Headline

Elastic Headline

A headline strung on an elastic. The letters are nodes on a mass-spring chain pinned a letter-pitch past each end, so every letter can be pulled, and coupled by the discrete Laplacian — so a pull travels outward to the neighbours and reflects off the ends, which is what makes it one object rather than letters that each happen to wobble. Grab one and drag.

Usage

import ElasticHeadline from '@/components/elastic-headline'

<ElasticHeadline
  text="Interfaces that move"
  stiffness={900}
  anchor={120}
  damping={5.2}
/>

Installation

npx shadcn@latest add https://morphiq.prathampatel.design/r/elastic-headline.json

Model

m·ÿᵢ = k·(yᵢ₋₁ − 2yᵢ + yᵢ₊₁) + η·(ẏᵢ₋₁ − 2ẏᵢ + ẏᵢ₊₁) − kₐ·yᵢ − c·ẏᵢ

a mass-spring chain, one node per letter, pinned a pitch past each end of each row · k coupling · η the elastic’s friction · kₐ anchor · c air

Props

PropertyTypeDefaultDescription
textstring'Interfaces that move'Rendered per glyph, and used as the element's accessible name.
stiffnessnumber900Neighbour coupling. This is the term that makes the line a wave.
anchornumber120Pull back to the resting slot. Higher settles flatter, faster.
dampingnumber5.2Air resistance: damps every mode of the line alike, the slow sway included.
viscositynumber3The elastic's own friction, acting on how fast neighbours move apart. It quiets the short ripples a release throws off and barely touches the sway; 0 leaves only damping.
massnumber1Per-letter mass. Heavier rings lower and longer.
grabnumber1How much of the pointer's travel a held letter takes, 0..1.
stretchnumber1.2How far, in em, a held letter follows the pointer one-to-one before the elastic resists; past it the letter gains only logarithmically. Infinity follows the pointer exactly.
reachnumber2How far a hover nudge spreads, in letters.
nudgenumber0Vertical push from hovering, in px. 0 makes the component drag-only.
liftnumber0.35How much vertical displacement tilts a glyph.