# Text shimmer

A band of light that sweeps through live words at an even pace, in grey or in the blue, violet and pink glint, while the words keep their own color.

Tier: free. Type: component. Category: text. Tags: agent, streaming, motion.

## Install

```bash
npx shadcn@latest add https://pixilui.com/r/text-shimmer.json
```

One-time setup: add the registry to `components.json`:

```json
{
  "registries": {
    "@pixilui": "https://pixilui.com/r/{name}.json"
  }
}
```

Files: `components/pixilui/text-shimmer.tsx`.

## Preview

Live preview: https://pixilui.com/components/text-shimmer

Knobs:

- `tone`: `grey`, `color`
- `live`: `live`, `done`

Signature: The band is the words' own color washed toward white, so black text gets a light band that you can actually see, and in dark the live words dim a step to make room for it.

Styles: `lively` (default), `quiet`, set with `data-style` on <html>. The item reads the style through the foundation; it needs no prop. Standalone files: lively https://pixilui.com/r/standalone/text-shimmer.tsx, quiet https://pixilui.com/r/standalone/text-shimmer.quiet.tsx.

## Code

`components/pixilui/text-shimmer.tsx`

```tsx
"use client";

/*
  The text shimmer, locked 30 Nov 2026 (design/explorations/components/locked/text-shimmer), foundation
  motion A. The look and motion are foundation.css section 8 (.pixilui-text-shimmer): a band of light
  sweeps through the words at an even pace (3.2s, linear, endless), and the words keep their own color.

  Grey    the words washed toward white at the band.
  Color   the band passes blue, violet and pink (data-shimmer="color"), the composer's Think glint.
  Dark    live text sits in the muted ink so the band can brighten it.
  Paused  data-paused holds the sweep while the text is off-screen (watched here).
  Ended   live=false: plain text in its own color.
  Reduced no band: plain text.
*/

import { forwardRef, useCallback, useEffect, useRef, type ComponentPropsWithoutRef } from "react";
import { cn } from "./lib/utils";

export type TextShimmerProps = ComponentPropsWithoutRef<"span"> & {
  /** grey (the default) or color (blue, violet and pink). */
  tone?: "grey" | "color";
  /** Whether the work is live. Off, the words are plain text in their own color. */
  live?: boolean;
};

/** Live words with a band of light passing through them, for as long as something is happening. */
export const TextShimmer = forwardRef<HTMLSpanElement, TextShimmerProps>(function TextShimmer({ tone = "grey", live = true, className, children, ...props }, forwarded) {
  const ref = useRef<HTMLSpanElement | null>(null);
  const setRef = useCallback(
    (el: HTMLSpanElement | null) => {
      ref.current = el;
      if (typeof forwarded === "function") forwarded(el);
      else if (forwarded) forwarded.current = el;
    },
    [forwarded],
  );
  // pause the sweep while the words are off-screen (looping motion never runs where no one sees it)
  useEffect(() => {
    const el = ref.current;
    if (!live || !el || typeof IntersectionObserver === "undefined") return;
    const io = new IntersectionObserver((entries) => entries.forEach((e) => (e.target as HTMLElement).toggleAttribute("data-paused", !e.isIntersecting)));
    io.observe(el);
    return () => {
      io.disconnect();
      el.removeAttribute("data-paused");
    };
  }, [live]);
  return (
    <span ref={setRef} className={cn(live && "pixilui-text-shimmer", className)} data-shimmer={live && tone === "color" ? "color" : undefined} {...props}>
      {children}
    </span>
  );
});
```

## Usage

When to use:

- The words of something live: "Searching 12 sources", "Thinking", "Generating your report".
- A Think or reasoning label, in the color tone.

When not to use:

- Loading placeholders where nothing is written yet: use a skeleton.
- Finished text: set live to false and the words are plain again.
- Decoration: the band means work is happening.

```tsx
import { TextShimmer } from "@/components/pixilui/text-shimmer";

// The first option of each knob is the demo's default; the docs preview starts there.
export const knobs = {
  tone: ["grey", "color"],
  live: ["live", "done"],
} as const;

/** A line, a muted line and a title, live or done. */
export default function TextShimmerDemo({ tone = "grey", live = "live" }: KnobValues<typeof knobs>) {
  const on = live === "live";
  return (
    <div className="flex w-full max-w-md flex-col gap-3">
      <p className="type-heading text-foreground">
        <TextShimmer tone={tone} live={on}>
          {on ? "Generating your report" : "Report ready"}
        </TextShimmer>
      </p>
      <p className="type-body text-foreground">
        <TextShimmer tone={tone} live={on}>
          {on ? "Searching 12 sources for the launch numbers" : "Read 12 sources, cited 4"}
        </TextShimmer>
      </p>
      <p className="type-caption text-muted">
        <TextShimmer tone={tone} live={on}>
          {on ? "Reading churn-2026-11.csv" : "Read churn-2026-11.csv, 2,318 rows"}
        </TextShimmer>
      </p>
    </div>
  );
}
```

## Examples

None.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `tone` | `"grey" \| "color"` | `"grey"` | grey (the default) or color (blue, violet and pink). |
| `live` | `boolean` | `true` | Whether the work is live. Off, the words are plain text in their own color. |

Also accepts every native `<span>` attribute, and a ref to it.

## Keyboard

- `Tab`: Never takes focus: the shimmer is the words' look.

## Accessibility

- The words are ordinary text, read as they are; the band is paint only.
- Put the live region on the place that changes, never on the shimmer.
- Every tone keeps the words' contrast: the band is always lighter than the text, and in dark the live words sit a step down so the band can brighten them.

## Motion

- One sweep takes 3.2s, linear and endless: the band is on the words about 60% of each pass and off them the rest.
- The sweep pauses while the words are off-screen.
- While the words swap (a library Swap carrying the class), the band steps aside.
- Reduced motion: no band, plain text.

## Responsive

- The band is sized to the words' own width, so it reads the same on a word and on a long line.

## Performance

- One CSS animation of a background position; off-screen it is paused by an IntersectionObserver.

## Notes for AI

- <TextShimmer>Searching 12 sources</TextShimmer>; tone="color" for the blue, violet and pink glint.
- Pass live={false} when the work ends: the words become plain text in their own color.
- Parts that draw their own live text can wear the class pixilui-text-shimmer (data-shimmer="color" for the glint).
- The words inherit their color; set it on the shimmer or its parent.

## Related

- [Agent status](https://pixilui.com/components/agent-status/markdown): A run's live state in a pill, queued, running, waiting on you, done, failed or stopped, that fills as it goes and closes into its result.
- [Action button](https://pixilui.com/components/action-button/markdown): Buttons that show their own work, so the page needs no toast: Save to Saving to Saved, Upload that fills its own glass, and Generate that becomes its own Stop with the elapsed time.
