Components
Shimmer
A utility class that moves a band of light across a line of text, to show that something is in progress.
Put shimmer on the element that holds the text. A band of light moves across the letters, from the start of the line to the end, and repeats every two seconds.
The band is made from the text's own colour, currentColor, so set the text colour as usual and the shimmer follows it, in light and dark. Only the letters are lit: there is no box or background behind them.
It respects prefers-reduced-motion by itself. With reduced motion on, the text is plain and still.
The utility comes from shadcn/tailwind.css, which each app imports in its globals.css.
Dex is reading your CV…
export function ShimmerDefault() {
return <p className="shimmer text-sm text-muted-foreground">Dex is reading your CV…</p>
}
Found 12 roles
'use client'
import { useState } from 'react'
import { Button } from '@dex/shared/components/button'
export function ShimmerWhileWorking() {
const [isSearching, setIsSearching] = useState(false)
const search = () => {
setIsSearching(true)
window.setTimeout(() => setIsSearching(false), 3000)
}
return (
<>
<Button variant="outline" disabled={isSearching} onClick={search}>
Search again
</Button>
<p role="status" className="text-sm text-muted-foreground">
<span className={isSearching ? 'shimmer' : undefined}>
{isSearching ? 'Searching for roles…' : 'Found 12 roles'}
</span>
</p>
</>
)
}
Looking for roles in London…
Looking for roles in London…
export function ShimmerColour() {
return (
<div className="grid gap-2 text-sm">
<p className="shimmer text-muted-foreground">Looking for roles in London…</p>
<p className="shimmer text-muted-foreground shimmer-color-brand/60">
Looking for roles in London…
</p>
</div>
)
}
shimmer-duration-1000
shimmer-spread-24
shimmer-angle-45
export function ShimmerTiming() {
return (
<div className="grid w-full gap-4 font-mono text-sm text-muted-foreground sm:grid-cols-3">
<p className="shimmer shimmer-duration-1000">shimmer-duration-1000</p>
<p className="shimmer shimmer-spread-24">shimmer-spread-24</p>
<p className="shimmer shimmer-angle-45">shimmer-angle-45</p>
</div>
)
}
shimmer shimmer-once
shimmer md:shimmer-none
export function ShimmerOnceAndOff() {
return (
<div className="grid gap-4 font-mono text-sm text-muted-foreground">
<p className="shimmer shimmer-once shimmer-duration-1100">shimmer shimmer-once</p>
<p className="shimmer md:shimmer-none">shimmer md:shimmer-none</p>
</div>
)
}
| Class | What it does |
|---|---|
shimmer |
Turns the shimmer on |
shimmer-color-brand/60 |
Sets the colour of the band, with an opacity after the slash. The default is a lighter version of the text colour |
shimmer-duration-1000 |
One pass, in milliseconds. The default is 2000 |
shimmer-spread-24 |
The width of the band, on the spacing scale or as a length |
shimmer-angle-45 |
The slant of the band, in degrees. The default is 20 |
shimmer-once |
One pass, then the text is plain |
shimmer-reverse |
Runs from the end of the line to the start |
shimmer-none |
Turns it off, for example from a breakpoint: md:shimmer-none |
- Shimmer is for a line of status text while something is happening. In the chat it is on the typing indicator and on the status line of a tool Dex is running.
- Take the class off when the work is done, so a finished status is still.
- Content that has not loaded yet has the skeleton, and a button that is working has its
loadingprop.