motion-stretch
Spring-physics letter spacing on hover. Characters elastically spread apart when the cursor enters and snap back when it leaves.
Preview
Import
Usage
Spread
spread controls how far the outermost characters move (in px per side). Higher values give a more dramatic stretch.
Spring tuning
Adjust stiffness and damping to change the character of the snap. High stiffness + low damping is bouncy; low stiffness + high damping is slow and smooth.
How it works
Each character is wrapped in an inline-block span. On mouseenter, Motion One animates each character's x transform using a spring — characters at the edges travel furthest (±spread), characters near the center barely move. On mouseleave, a new spring animation returns all characters to x: 0.
Any in-progress animation is cancelled before starting the next, so fast hover transitions always feel responsive rather than lagging.
Accessibility
The animated per-character spans are marked aria-hidden="true", and the full text string is exposed to assistive tech via a visually-hidden span inside the shadow DOM. Screen readers announce the word as a single phrase rather than letter-by-letter, regardless of the spring transforms applied to individual characters.
When composing inside another text component (e.g. motion-scramble), pass the text only once — either as the parent's content or as motion-stretch's text attribute, not both — to avoid duplicate announcements.
Properties
| Attribute | Property | Type | Default | Description |
|---|---|---|---|---|
| | | string | — | Text to render |
| | | number | 12 | Max displacement of the outermost character on each side (px) |
| | | number | 320 | Spring stiffness — higher is snappier |
| | | number | 16 | Spring damping — lower is bouncier |