Scatter Text

Letters knocked out of place that people can drag about, and that spring back on cue.

Page not found

Drag the letters about, or put them back in one go.

'use client';

import { useState } from 'react';
import { Button, ScatterText } from '@brand-studio/ui';

export default function ScatterTextDemo() {
  const [tidy, setTidy] = useState(false);
  return (
    <div style={{ display: 'grid', justifyItems: 'center', gap: 20, textAlign: 'center' }}>
      <h2 style={{ margin: 0, fontSize: 'clamp(2.4rem, 9vw, 4.5rem)', fontWeight: 800 }}>
        <ScatterText text="Page not found" tidy={tidy} />
      </h2>
      <p style={{ margin: 0, maxWidth: '30ch', color: 'var(--bs-muted)' }}>Drag the letters about, or put them back in one go.</p>
      <Button tone="secondary" onClick={() => setTidy(value => !value)}>{tidy ? 'Knock it over' : 'Put it back'}</Button>
    </div>
  );
}

Installation

pnpm add @brand-studio/ui

Usage

import { ScatterText } from '@brand-studio/ui';
<h1><ScatterText text="Page not found" tidy={tidy} /></h1>
<Button tone="secondary" onClick={() => setTidy(true)}>Put it back</Button>

The letters scatter after the page loads and spring back when tidy turns on. spread scales how far they fall; the default keeps them clear of the line below. Words wrap as whole words.

Accessibility

  • Screen readers hear the plain text once; the loose letters are hidden from them.
  • The server renders the text in order, so it reads correctly before scripts run.
  • Under reduced motion the letters stay in place.

API Reference

PropTypeDefault
textstring–
tidy?booleanfalse
spread?number1
as?React.ElementType–
className?string''

Still, Deskhand and Hollis are fictional brands. The coffee photographs are original generated artwork. @brand-studio/ui is MIT licensed.