--- title: shimmer description: Utilities for adding a shimmer effect to text elements. --- ## Installation If your project was set up with `npx shadcn@latest init`, you already have `shimmer`. It ships with the `shadcn` package, which the CLI imports in your global CSS file. Otherwise, install the `shadcn` package: ```bash npm install shadcn ``` Then import the shared utilities in your global CSS file: ```css @import "tailwindcss"; @import "shadcn/tailwind.css"; ``` ## Usage | Class | Styles | | ----------------------------- | ---------------------------------------------------------------------------------------------------- | | `shimmer` | `background-clip: text;`
`animation: tw-shimmer var(--shimmer-duration, 2s) linear infinite;` | | `shimmer-once` | `animation-iteration-count: 1;` | | `shimmer-reverse` | `animation-direction: reverse;` | | `shimmer-none` | `--shimmer-image: none;`
`--shimmer-text-fill: currentColor;` | | `shimmer-color-` | `--shimmer-color: ;` | | `shimmer-color-[]` | `--shimmer-color: ;` | | `shimmer-color-/` | `--shimmer-color: color-mix(in oklch, , transparent);` | | `shimmer-duration-` | `--shimmer-duration: calc( * 1ms);` | | `shimmer-spread-` | `--shimmer-spread: calc(var(--spacing) * );` | | `shimmer-spread-[]` | `--shimmer-spread: ;` | | `shimmer-angle-` | `--shimmer-angle: calc( * 1deg);` | Add `shimmer` to a text element. ```tsx

Generating response…

``` The shimmer is built on `currentColor`, so it adapts to the element: - The highlight is derived from the text color, with no configuration needed. - It works on any color, from `text-muted-foreground` to brand colors. - In dark mode, the highlight automatically brightens to stay visible. The effect is pure CSS. The text is painted with `background-clip: text`, and the highlight sweeps across it in a seamless loop. ## With Marker The shimmer composes with any component that renders text. A common pattern is a [Marker](/docs/components/marker) showing a live status while the assistant is working: ```tsx Thinking… ``` ## Color Use `shimmer-color-` to set the highlight color explicitly. It accepts theme colors with an optional opacity modifier, or any arbitrary color value. ```tsx

Generating response…

Generating response…

``` ## Duration Use `shimmer-duration-` to set the duration of one sweep in milliseconds. The default is `2000`, i.e. `2s`. ```tsx

Generating response…

``` ## Spread Use `shimmer-spread-` to set the width of the highlight band using the spacing scale. The default is `calc(3ch + 40px)`: a fixed base plus a `3ch` term that scales with the font size. ```tsx

Generating response…

``` For one-off values, use an arbitrary length or percentage: ```tsx

Generating response…

``` ## Angle Use `shimmer-angle-` to set the tilt of the highlight band in degrees. The default is `20`. ```tsx

Generating response…

``` ## Reverse Use `shimmer-reverse` to sweep the highlight in the opposite direction. In RTL layouts the sweep already follows the reading direction. See [RTL](#rtl). ```tsx

Generating response…

``` ## Play Once Use `shimmer-once` to play a single sweep instead of looping, useful as a reveal when streaming completes. Pair it with `shimmer-duration-` to control how long the sweep takes. ```tsx

Response generated.

``` ## Disabling the Shimmer Use `shimmer-none` to turn the effect off and render the text normally. It works in any class order, so the typical use is responsive or stateful: ```tsx

Generating response…

``` ## Fallback The shimmer is built on modern color features, [relative color syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Relative_colors) and `color-mix()`, which are available in all current browsers. In older browsers without support, the highlight gradient is dropped and the text can render transparent. If you target older browsers, apply `shimmer` conditionally with a `supports-*` variant: ```tsx

Generating response…

``` ## Reduced Motion When the user prefers reduced motion, the animation is disabled automatically and the text renders normally. There is nothing to configure. ## RTL To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl). The sweep follows the reading direction, left to right in LTR and right to left in RTL, with no extra classes. Use `shimmer-reverse` to flip the direction manually.