A paint roller rolls across a stripe and leaves color behind it, then the paint fades and the stroke starts over. Pure CSS, no animation library. The paint takes the primary token and can be changed with a CSS variable.
Browser Support
Feature
Baseline
Your browser
color-mix()
Mixes paint and highlight colors
Your browser:
Preview
Preparing your workspace
Installation
Usage
import { PaintRollerLoader } from "@/components/ui/paint-roller-loader"
export default function Example() {
return <PaintRollerLoader size={220} label="Preparing your workspace" />
}Examples
Size and speed
size sets the width in px, everything else scales with it. duration is one stroke in ms.
Loading
Loading
Loading
<PaintRollerLoader size={80} />
<PaintRollerLoader size={140} duration={1800} />
<PaintRollerLoader size={200} duration={3200} />Colors
Override --paint-roller-color for the paint, --paint-roller-frame for the handle and --paint-roller-track for the unpainted stripe.
Loading
Applying the new theme
<PaintRollerLoader
style={{ "--paint-roller-color": "var(--chart-1)" } as React.CSSProperties}
/>
// or with Tailwind
<PaintRollerLoader className="[--paint-roller-color:var(--chart-2)]" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| size | number | 160 | Width of the illustration in px |
| duration | number | 2400 | One stroke cycle, ms |
| label | ReactNode | - | Visible caption under the roller |
| srLabel | string | "Loading" | Screen reader text when there is no caption |
| className | string | - | Additional CSS classes |
| style | CSSProperties | - | Inline styles, a place for the CSS variables |
CSS variables
| Variable | Default | Description |
|---|---|---|
| --paint-roller-color | var(--primary) | Paint color |
| --paint-roller-frame | var(--foreground) | Handle and roller outline |
| --paint-roller-track | var(--muted) | Unpainted stripe |
Features
- Pure CSS: three keyframes, no JavaScript and no motion
- Scales: geometry is in em, one font-size resizes the drawing
- Accessible: role="status", the caption or srLabel is announced
- Reduced motion: the roller stops halfway along a painted stripe