Skip to main content

TextScramblerEffect

Client component that cycles random characters at fixed string length while isActive, for placeholder loading without revealing real labels.

Exports​

  • TextScramblerEffect — function component
  • TextScramblerEffectProps — interface

Props (TextScramblerEffectProps)​

PropTypeDefaultBehavior
originalTextstring—Target length and recovery text when inactive
isActiveboolean—Enables interval scrambling
speednumber50Interval ms
charactersstringalphanumeric setPool when useSameCharacters is false
useSameCharactersbooleanfalseScramble using only chars from originalText
respectWordBoundariesbooleanfalsePer-word char pools when combined with same-char mode
classNamestring''On visible span
childrenReactNode—Rendered when inactive instead of originalText

Behavior​

  • When useSameCharacters, measures max width via hidden span (calculateMaxWidth) and sets minWidth to avoid layout shift; waits for calculation before scrambling.
  • Inactive: children or originalText; active: visible scrambled text is aria-hidden with SR-only "Loading decoration for …".
  • Preserves spaces, _, and - in all scramble modes.

Sources: src/app/components/decoration/TextScramblerEffect.tsx, src/app/components/decoration/TextScramblerEffect.css