Skip to content

AnimateScramble

Text arriving through noise, one character at a time. AnimateTyping's sibling: a typewriter reveals a string from an empty line, this one resolves it out of a line that was already the right length.

tsx
import { AnimateScramble } from 'neba';

<AnimateScramble text="RESOLVING SIGNAL" />;

Props

PropTypeDefaultDescription
textstringThe text, when it is easier to pass than to nest. Overrides children
speednumber18How fast the text settles, in characters per second. duration wins when it is given
ticknumber45How often an unsettled character is redrawn, in milliseconds. Below about 30 it stops reading as characters
charactersstringThe pool an unsettled character is drawn from. Glyphs of different heights make the line jump
localestringWhich language the text is in
durationsharednumberHow long one run takes, in milliseconds
delaysharednumber0How long before it starts, in milliseconds
easingstringThe easing curve, as CSS writes it. Defaults to the house curve
repeatsharednumber | 'infinite'1How many times it runs
alternatesharedbooleanfalseRuns every other pass backwards, so a repeat returns instead of jumping
triggershared'mount' | 'visible' | 'hover' | 'manual''mount'What starts it. visible is on scrolling into view, hover is under the pointer (focus counts), manual is whatever play says
playbooleanRuns it when trigger is manual. Each false → true starts it over
oncesharedbooleantrueWith trigger="visible", whether it runs only the first time. Off, it runs again on every return
thresholdsharednumber0.2With trigger="visible", how much of the element has to be on screen, from 0 to 1
pausedsharedbooleanfalseHolds the animation where it is
renderuseRender.RenderPropRenders something other than a div (render={<h2 />}). Base UI's own escape hatch
childrenReactNodeThe text to settle

Every other <div> attribute passes through to the root. The settings shared by every Animate* are defined in prop conventions.

The box never changes size, which is the whole reason to choose this over AnimateTyping: nothing around it reflows, and a heading does not push the page down as it lands.

Whitespace is never scrambled. A space that flickered into a letter and back would read as the words having moved, which is the one thing this effect exists to avoid.

Examples

speed, duration and tick

speed is how many characters settle per second; duration is the whole run and wins when it is given, so the per-character delay falls out of it rather than being asked for twice. tick is how often an unsettled character is redrawn: below about 30 milliseconds it stops reading as characters at all.

characters

The pool an unsettled character is drawn from. Keep the glyphs one height: a pool with tall and short characters in it makes the line jump as it settles.

Accessibility

  • The finished string is in the document from the first frame, in a clipped box for a screen reader; the noise is a visible copy that is aria-hidden.
  • A reduced-motion preference shows the text straight away.
  • Do not scramble something a reader has to act on quickly. It is legible only at the end.

Released under the MIT License