A modern, highly customizable React component that animates a shimmer effect over text. Great for loading states, eye-catching headlines, or subtle UI highlights. Inspired by the best shimmer text patterns in modern UIs.
You can install the TextShimmer component with the following CLI command, or copy the implementation manually:
1npx shadcn@latest add http://localhost:3000/r/text-shimmer.jsonTo use the TextShimmer component, import it in your code:
1import TextShimmer from '@/components/TextShimmer';The TextShimmer component accepts the following props:
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
children | string | - | The text to shimmer. | Yes |
duration | number | 3 | Duration of the shimmer animation (in seconds). | No |
spread | number | 2 | Visual width of the shimmer highlight (multiplied by children length). | No |
baseColor | string | #FFF | The base color of the text. | No |
shimmerColor | string | #000 | The color of the shimmer animation/gradient. | No |
className | string | - | Additional utility classes for fine-tuning the shimmered text. | No |
1interface TextShimmerProps {
2 duration?: number;
3 children: string;
4 className?: string;
5 spread?: number;
6 baseColor?: string;
7 shimmerColor?: string;
8}1<TextShimmer>Text Shimmer</TextShimmer>1<TextShimmer duration={5} spread={4}>Custom Text Shimmer</TextShimmer>1<TextShimmer baseColor="#333" shimmerColor="#fbbf24">Gold Shimmer!</TextShimmer>1<TextShimmer className="text-xl font-bold uppercase">Bigger & Bold</TextShimmer>duration prop (in seconds)spread prop (higher = wider shimmer)baseColor and shimmerColorclassName prop for font size, weight, color, etc.children prop is a string (not JSX/element) or the effect will not render as intended.backgroundImage or CSS variables.