Shimmer
Utilities for animated text highlights in loading and thinking states.
Loading preview…
1<script lang="ts">
2 import { shimmerClass, shimmerColorClasses, shimmerDurationClasses } from "./shimmer.js";
3</script>
4
5<div class="flex flex-col items-center gap-4 text-sm text-muted-foreground">
6 <p class={shimmerClass}>Generating response…</p>
7 <p class={`${shimmerClass} ${shimmerColorClasses.brand}`}>Thinking through the details…</p>
8 <p class={`${shimmerClass} ${shimmerDurationClasses[1000]}`}>Preparing your workspace…</p>
9</div>
10Installation
1. Install dependencies
Usage
These class helpers use the utilities shipped in shadcn-svelte/tailwind.css. The design system Styles already imports them. In other projects, add this once to your global CSS:
1@import "tailwindcss";
2@import "shadcn-svelte/tailwind.css"; 1<script lang="ts">
2 import { shimmerClass } from "~/lib/shimmer";
3</script>
4
5<p class={`${shimmerClass} text-sm text-muted-foreground`}>Generating response…</p> | Class | Effect |
|---|---|
shimmer | Repeat a highlight across text |
shimmer-once | Play one sweep |
shimmer-reverse | Reverse the sweep |
shimmer-none | Show solid text |
shimmer-color-* | Set the highlight color |
shimmer-duration-<ms> | Set animation duration |
shimmer-spread-<n> | Set the band width |
shimmer-angle-<deg> | Set the band angle |
Exports include shimmerClass, shimmerOnceClass, shimmerReverseClass, shimmerNoneClass, and the duration, spread, angle, and color class maps. The brand color helper uses Svelte orange. Write custom utilities as complete class names so Tailwind detects them.
The upstream utility follows text direction and disables motion for the user’s reduced-motion preference. Keep loading status available as readable text; shimmer is decorative.