Text shimmer
FreeA 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.
npx shadcn@latest add https://pixilui.com/r/text-shimmer.jsonPreview
A lighter band sweeps through live words at an even pace.
Tone
Live
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>
);
}When to use
Use it when
- The words of something live: "Searching 12 sources", "Thinking", "Generating your report".
- A Think or reasoning label, in the color tone.
Use something else when
- 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.
Installation
Terminal
npx shadcn@latest add https://pixilui.com/r/text-shimmer.jsonAdds text-shimmer.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.
components/pixilui/text-shimmer.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>
);
});
Then npm i clsx tailwind-merge, and add the foundation once per app, as in Installation.
Usage
example.tsx
import { TextShimmer } from "@/components/pixilui/text-shimmer";
<TextShimmer />The band is sized to the words' own width, so it reads the same on a word and on a long line.
API reference
PropTypeDefault
tone"grey" | "color""grey"grey (the default) or color (blue, violet and pink).livebooleantrueWhether the work is live. Off, the words are plain text in their own color.Also takes every native <span> attribute, and a ref.
Keyboard
TabNever 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.