Typography
FreeShimmer Text
The 'thinking…' and 'working…' look for in-progress labels, skeleton titles and quiet emphasis.
Install
No key needed.
npx @galactrex/ui add shimmer-textUsage
import { ShimmerText } from "@/components/galactrex/shimmer-text";
<ShimmerText>Generating your brief…</ShimmerText>Source
Installs to components/galactrex/shimmer-text.tsx, with the shared motion primitives beside it.
"use client";
import type { ElementType, ReactNode } from "react";
import { cx } from "@/components/galactrex/motion/cx";
import { useReducedMotion } from "@/components/galactrex/motion/use-reduced-motion";
export type ShimmerTextProps = {
children: ReactNode;
as?: ElementType;
/** seconds for one pass */
duration?: number;
/** width of the light band as a share of the text, 0.1 to 0.6 */
spread?: number;
className?: string;
};
/** Muted text with a band of light sweeping across it, the way an assistant shows it is "thinking" or a loader
says "working". For in-progress labels, skeleton titles and quiet emphasis. The text is fully readable
throughout; reduced motion leaves it plain. */
export function ShimmerText({ children, as: Tag = "span", duration = 2, spread = 0.25, className }: ShimmerTextProps) {
const reduced = useReducedMotion();
const band = Math.round(Math.min(0.6, Math.max(0.1, spread)) * 50);
return (
<Tag
className={cx("bg-clip-text text-transparent", !reduced && "[animation:gxui-shimmer_var(--gxui-shimmer-time)_linear_infinite]", reduced && "text-gxui-muted", className)}
style={reduced ? undefined : {
backgroundImage: `linear-gradient(90deg, var(--gxui-muted) ${50 - band}%, var(--gxui-ink) 50%, var(--gxui-muted) ${50 + band}%)`,
backgroundSize: "250% 100%",
WebkitBackgroundClip: "text",
backgroundClip: "text",
["--gxui-shimmer-time" as string]: `${duration}s`,
}}
>
{children}
</Tag>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Text. |
as | ElementType | "span" | Element. |
duration | number | 2 | Seconds per pass. |
spread | number | 0.25 | Band width, 0.1 to 0.6. |
className | string | — | Extra classes for the outer element. |
Variants
- Thinking. Next to an agent's working state.
Accessibility
- Fully readable throughout.
Motion and reduced motion
- Background position loop.
- Reduced motion: plain muted text.