# Glitch Text

> Text that tears into offset accent slices every few seconds, like a lost signal.

```tsx
import { GlitchText } from '@brand-studio/ui';

export default function GlitchTextDemo() {
  return (
    <div style={{ display: 'grid', justifyItems: 'center', gap: 12, textAlign: 'center' }}>
      <div style={{ font: '800 clamp(5rem, 22vw, 9rem)/1 ui-monospace, SFMono-Regular, Menlo, monospace', letterSpacing: '-.04em' }}>
        <GlitchText text="404" />
      </div>
      <p style={{ margin: 0, color: 'var(--bs-muted)' }}>Lost signal. This page is not here.</p>
    </div>
  );
}
```

## Installation

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, GlitchText } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { GlitchText } from '@brand-studio/ui';
```

```tsx
<NotFound art={<GlitchText text="404" />} />
```

It takes the font and size of its parent, so set those on the element around it. Keep it to a number or a word or two.

## Accessibility

- Screen readers hear the text once; the two torn copies are hidden from them.
- The tear lasts a fraction of a second every three seconds and never flashes the whole text.
- Under reduced motion the slices hold still as one fixed tear.

## API Reference

| Prop | Type | Default |
|---|---|---|
| `text` | `string` | – |
| `as?` | `React.ElementType` | – |
| `className?` | `string` | `''` |

Source: https://brandstudio.js.org/docs/components/glitch-text/
