$npx @dinachi/cli@latest add text-shimmer
Thinking…
childrenvariantdurationdimthinking.tsx
import { TextShimmer } from "@/components/ui/text-shimmer"
export function Thinking({ pending }: { pending: boolean }) {
return pending ? <TextShimmer>Thinking…</TextShimmer> : null
}Usage
import { TextShimmer } from "@/components/ui/text-shimmer"
export function Thinking({ pending }: { pending: boolean }) {
return pending ? <TextShimmer>Thinking…</TextShimmer> : null
}Examples
Thinking…
A band travelling across a pending label.
import { TextShimmer } from '@/components/ui/text-shimmer';
export function Example() {
return <TextShimmer className="text-lg">Thinking…</TextShimmer>;
}Sweeping a band acrossBreathing dim to lit
A travelling band, or the whole label breathing.
import { TextShimmer } from '@/components/ui/text-shimmer';
export function Example() {
return (
<div className="flex flex-col gap-4 text-lg">
<TextShimmer variant="sweep">Sweeping a band across</TextShimmer>
<TextShimmer variant="pulse">Breathing dim to lit</TextShimmer>
</div>
);
}Waiting for a question
Mounted when the work starts, gone when it lands.
import { useState } from 'react';
import { TextShimmer } from '@/components/ui/text-shimmer';
export function Example() {
const [reply, setReply] = useState<string | null>(null);
const [pending, setPending] = useState(false);
async function ask() {
setPending(true);
setReply(await generate());
setPending(false);
}
// Unmounting is what stops the loop. Leaving it up over a settled answer
// turns a signal into decoration.
return pending ? <TextShimmer>Generating a reply…</TextShimmer> : <p>{reply}</p>;
}Barely dimmedDefaultDeeply dimmed
How far the un-lit text drops.
import { TextShimmer } from '@/components/ui/text-shimmer';
export function Example() {
return (
<div className="flex flex-col gap-4 text-lg">
<TextShimmer dim={0.85}>Barely dimmed</TextShimmer>
<TextShimmer dim={0.7}>Default</TextShimmer>
<TextShimmer dim={0.4}>Deeply dimmed</TextShimmer>
</div>
);
}Notes
Mounting
It loops while mounted. Mount it when the work starts; unmount it when the work lands.
Variants
sweepfor label-sized text.pulsefor dense or small text. It animates only opacity, so it is cheaper.
Both use currentColor and follow the theme.
Size
sweep animates background-position, which repaints the box every frame. Use it on a label, never a paragraph.
Motion tier
Needs motion. add --all skips it; install with add --motion or by name.
API
variant"sweep" | "pulse" = "sweep"
A highlight band across the text, or the whole label pulsing.durationnumber = 1.6 sweep, 1.8 pulse
Seconds for one cycle.dimnumber = 0.7
Brightness of un-lit text, 0 to 1. Keep it readable.Accessibility
- The span has
role="status". - Reduced motion stops the loop; the dim colour remains.