# Shimmer

A label with a moving sheen that says work is under way.

A label with a moving sheen that says work is under way: an agent thinking, a page loading. Shimmering label: signals the agent is processing. A moving ink highlight clipped to the text; tone accent sweeps in the accent hue.

Kind: component · Category: Feedback · Status: stable · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add shimmer
```

It writes the folder `shimmer/` into the project's ui folder (`index.ts`, `shimmer.tsx`, `Shimmer.vue`, `Shimmer.svelte`, `shimmer.recipe.ts`). First time: [Installation](/installation.md).

## Usage

```tsx
import { Shimmer } from "@/components/ui/shimmer";
```

```vue
import { Shimmer } from "@/components/ui/shimmer";
```

```svelte
import { Shimmer } from "$lib/components/ui/shimmer";
```

## Parts

In the DOM the root carries `data-slot="shimmer"` and each part `data-slot="shimmer-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `span` | `shimmer` |  |  |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `speed` | `"normal" \| "fast"` | `"normal"` |  |
| `tone` | `"ink" \| "accent"` | `"ink"` | ink or accent: accent text with an accent-ink highlight (fine-tune-card's "Adjust" hint). |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Slots

| Slot | Content |
| --- | --- |
| `default` | Text |

## Keyboard and accessibility

Notes:

- The text is real text. Put the shimmer in a role="status" region when it announces work in progress.

## Motion

- background-position sweep, 1.8s linear, forever (1.4s when fast)
- prefers-reduced-motion: the sweep stops and the label shows as static ink-2 text (accent text for tone accent)
- forced-colors: static system text colour (background images are dropped there)

## Tokens

`color.ink`, `color.ink-2`, `color.ink-3`, `color.accent`, `color.accent-ink`

## Examples

### Agent working through a fix

React · `agent-steps.tsx`

```tsx
import { Check, Sparkle } from "@phosphor-icons/react";
import { Shimmer } from "@/components/ui/shimmer";

const done = ["Read the failing test in webhooks.test.ts", "Found the 10 s timeout in deliver()"];

export default function AgentSteps() {
  return (
    <ol className="flex w-80 max-w-full flex-col gap-2 text-sm">
      {done.map((step) => (
        <li key={step} className="flex items-center gap-2 text-ink-2">
          <Check data-slot="icon" weight="bold" className="shrink-0 text-green" aria-hidden />
          {step}
        </li>
      ))}
      <li className="flex items-center gap-2">
        <Sparkle data-slot="icon" weight="fill" className="shrink-0 text-accent" aria-hidden />
        <Shimmer>Writing a retry with backoff…</Shimmer>
      </li>
    </ol>
  );
}
```

Vue · `agent-steps.vue`

```vue
<script setup lang="ts">
import { PhCheck, PhSparkle } from "@phosphor-icons/vue";
import { Shimmer } from "@/components/ui/shimmer";

const done = ["Read the failing test in webhooks.test.ts", "Found the 10 s timeout in deliver()"];
</script>

<template>
  <ol class="flex w-80 max-w-full flex-col gap-2 text-sm">
    <li v-for="step in done" :key="step" class="flex items-center gap-2 text-ink-2">
      <PhCheck data-slot="icon" weight="bold" class="shrink-0 text-green" aria-hidden="true" />
      {{ step }}
    </li>
    <li class="flex items-center gap-2">
      <PhSparkle data-slot="icon" weight="fill" class="shrink-0 text-accent" aria-hidden="true" />
      <Shimmer>Writing a retry with backoff…</Shimmer>
    </li>
  </ol>
</template>
```

Svelte · `agent-steps.svelte`

```svelte
<script lang="ts">
  import Check from "phosphor-svelte/lib/CheckIcon";
  import Sparkle from "phosphor-svelte/lib/SparkleIcon";
  import { Shimmer } from "$lib/components/ui/shimmer";

  const done = ["Read the failing test in webhooks.test.ts", "Found the 10 s timeout in deliver()"];
</script>

<ol class="flex w-80 max-w-full flex-col gap-2 text-sm">
  {#each done as step (step)}
    <li class="flex items-center gap-2 text-ink-2">
      <Check data-slot="icon" weight="bold" class="shrink-0 text-green" aria-hidden="true" />
      {step}
    </li>
  {/each}
  <li class="flex items-center gap-2">
    <Sparkle data-slot="icon" weight="fill" class="shrink-0 text-accent" aria-hidden="true" />
    <Shimmer>Writing a retry with backoff…</Shimmer>
  </li>
</ol>
```

### A short wait

React · `thinking.tsx`

```tsx
import { Shimmer } from "@/components/ui/shimmer";

export default function Thinking() {
  return (
    <p role="status" className="text-sm">
      <Shimmer speed="fast">Thinking</Shimmer>
    </p>
  );
}
```

Vue · `thinking.vue`

```vue
<script setup lang="ts">
import { Shimmer } from "@/components/ui/shimmer";
</script>

<template>
  <p role="status" class="text-sm">
    <Shimmer speed="fast">Thinking</Shimmer>
  </p>
</template>
```

Svelte · `thinking.svelte`

```svelte
<script lang="ts">
  import { Shimmer } from "$lib/components/ui/shimmer";
</script>

<p role="status" class="text-sm">
  <Shimmer speed="fast">Thinking</Shimmer>
</p>
```

### A hint that invites an action

React · `suggest-a-fix.tsx`

```tsx
import { WarningCircle } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { Shimmer } from "@/components/ui/shimmer";

export default function SuggestAFix() {
  return (
    <div className="flex w-80 max-w-full items-center gap-2 text-sm">
      <WarningCircle data-slot="icon" weight="fill" className="shrink-0 text-red" aria-hidden />
      <span className="min-w-0 flex-1 text-ink-2">Build failed on main · a1b2c3d</span>
      <Button size="sm" variant="ghost">
        <Shimmer speed="fast" tone="accent">Suggest a fix</Shimmer>
      </Button>
    </div>
  );
}
```

Vue · `suggest-a-fix.vue`

```vue
<script setup lang="ts">
import { PhWarningCircle } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { Shimmer } from "@/components/ui/shimmer";
</script>

<template>
  <div class="flex w-80 max-w-full items-center gap-2 text-sm">
    <PhWarningCircle data-slot="icon" weight="fill" class="shrink-0 text-red" aria-hidden="true" />
    <span class="min-w-0 flex-1 text-ink-2">Build failed on main · a1b2c3d</span>
    <Button size="sm" variant="ghost">
      <Shimmer speed="fast" tone="accent">Suggest a fix</Shimmer>
    </Button>
  </div>
</template>
```

Svelte · `suggest-a-fix.svelte`

```svelte
<script lang="ts">
  import WarningCircle from "phosphor-svelte/lib/WarningCircleIcon";
  import { Button } from "$lib/components/ui/button";
  import { Shimmer } from "$lib/components/ui/shimmer";
</script>

<div class="flex w-80 max-w-full items-center gap-2 text-sm">
  <WarningCircle data-slot="icon" weight="fill" class="shrink-0 text-red" aria-hidden="true" />
  <span class="min-w-0 flex-1 text-ink-2">Build failed on main · a1b2c3d</span>
  <Button size="sm" variant="ghost">
    <Shimmer speed="fast" tone="accent">Suggest a fix</Shimmer>
  </Button>
</div>
```

## Recipe

`shimmer.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* shimmer — shimmering label; signals the agent is processing. The text is a window onto a
 * gradient twice its width that slides across it (1.8s, 1.4s fast); it stops under reduced motion
 * and forced colours. @keyframes fndn-shimmer-text is in base.css; one element,
 * so the recipe is `base` only.
 *
 * Reduced motion: the label reads as plain secondary text. Forced colours drop background images,
 * which would leave the transparent text invisible: it takes the system text colour. */

export const shimmer = tv({
  base: [
    "inline-block bg-size-[200%_100%] bg-clip-text text-transparent",
    "animate-[fndn-shimmer-text_1.8s_linear_infinite] motion-reduce:animate-none forced-colors:animate-none",
    "motion-reduce:bg-none forced-colors:bg-none forced-colors:text-[color:CanvasText]",
  ],
  variants: {
    speed: {
      normal: "",
      fast: "motion-safe:not-forced-colors:animate-[fndn-shimmer-text_1.4s_linear_infinite]",
    },
    tone: {
      ink: "bg-[linear-gradient(90deg,var(--fndn-ink-3)_35%,var(--fndn-ink)_50%,var(--fndn-ink-3)_65%)] motion-reduce:text-ink-2",
      /* the same sweep in the accent hue, for a hint that invites an action */
      accent: "bg-[linear-gradient(90deg,var(--fndn-accent)_35%,var(--fndn-accent-ink)_50%,var(--fndn-accent)_65%)] motion-reduce:text-accent",
    },
  },
  defaultVariants: { speed: "normal", tone: "ink" },
});

export type ShimmerRecipeProps = VariantProps<typeof shimmer>;
```
