Audit coverage
The Checkout flow audit has 24 screens. 19 cells are filled and the line after the track says 5 left; each screen audited fills the next cell.
Components / FeedbackStable
Shows how far along something is as a row of small cells that ramp from a light to a deep accent blue. It reads at a glance when the amount counts whole things.
'use client'
import { useState, type CSSProperties, type ReactNode } from 'react'
// Nacre SegmentedProgress: how far along something is, as a row of small cells. It reads faster than a bar when
// the amount counts whole things (screens audited, lessons done). Progress (Progress.tsx) is the plain bar for a
// stream such as an upload. React plus Tailwind classes only; needs nacre-theme.css. The filled cells ramp from a
// light to a deep accent: a fixed ramp of color-mix steps on the accent role, so it follows both themes.
// Motion: when the value changes, the new cells fade and scale in left to right, 14 ms apart (quick 160, out),
// by opacity and scale only. It is display only, so a key press never starts it. Reduced motion and
// [data-nacre-motion="off"] change at once.
export type SegmentedProgressProps = {
label: string
/** Cells filled, from 0 to cells. */
value: number
/** How many cells the track has. */
cells?: number
/** A short line after the track, such as 5 left. */
trailing?: ReactNode
className?: string
}
/** The accent mixed toward white on the first half of the track and toward black on the second half. */
function ramp(i: number, n: number): string {
const t = n > 1 ? i / (n - 1) : 1
const white = Math.round(55 * Math.max(0, 1 - t * 2))
const black = Math.round(32 * Math.max(0, t * 2 - 1))
return `color-mix(in oklab, black ${black}%, color-mix(in oklab, white ${white}%, var(--nx-accent)))`
}
export function SegmentedProgress({ label, value, cells = 24, trailing, className = '' }: SegmentedProgressProps) {
const total = Math.max(1, Math.round(Number.isFinite(cells) ? cells : 24))
const filled = Math.min(Math.max(Math.round(Number.isFinite(value) ? value : 0), 0), total)
// The value before the last change decides which cells animate and in what order (stored in state, so render stays pure).
const [seen, setSeen] = useState(filled)
const [from, setFrom] = useState(filled)
if (seen !== filled) {
setFrom(seen)
setSeen(filled)
}
return (
<div data-part="root" className={`flex items-center gap-3.5 ${className}`}>
<div
role="progressbar"
aria-label={label}
aria-valuemin={0}
aria-valuemax={total}
aria-valuenow={filled}
data-part="track"
className="flex h-[26px] min-w-0 flex-1 gap-0.5 rounded-[10px] bg-sunken p-[3px]"
>
{Array.from({ length: total }, (_, i) => {
const on = i < filled
// Filling runs left to right from the first new cell; emptying runs right to left from the last one.
const step = filled >= from ? i - from : from - 1 - i
return (
<i
key={i}
data-part="cell"
className="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]"
>
<span
data-part="fill"
data-on={on ? '' : undefined}
style={{ backgroundColor: ramp(i, total), '--step': Math.min(Math.max(step, 0), 20) } as CSSProperties}
className={`absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] ${on ? 'scale-100 opacity-100' : 'scale-50 opacity-0'}`}
/>
</i>
)
})}
</div>
{trailing != null && <span data-part="trailing" className="shrink-0 text-body font-[500] whitespace-nowrap text-fg">{trailing}</span>}
</div>
)
}
<div data-part="root" class="flex items-center gap-3.5 ">
<div role="progressbar" aria-label="Checkout flow audit" aria-valuemin="0" aria-valuemax="24" aria-valuenow="19" data-part="track" class="flex h-[26px] min-w-0 flex-1 gap-0.5 rounded-[10px] bg-sunken p-[3px]">
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 55%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 50%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 45%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 41%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 36%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 31%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 26%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 22%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 17%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 12%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 7%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 0%, color-mix(in oklab, white 2%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 1%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 4%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 7%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 10%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 13%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 15%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" data-on="" style="background-color:color-mix(in oklab, black 18%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-100 opacity-100"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" style="background-color:color-mix(in oklab, black 21%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:0" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-50 opacity-0"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" style="background-color:color-mix(in oklab, black 24%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:1" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-50 opacity-0"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" style="background-color:color-mix(in oklab, black 26%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:2" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-50 opacity-0"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" style="background-color:color-mix(in oklab, black 29%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:3" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-50 opacity-0"></span>
</i>
<i data-part="cell" class="relative flex-1 rounded-[4px] bg-[color-mix(in_oklab,var(--nx-fg)_8%,var(--nx-sunken))]">
<span data-part="fill" style="background-color:color-mix(in oklab, black 32%, color-mix(in oklab, white 0%, var(--nx-accent)));--step:4" class="absolute inset-0 rounded-[inherit] motion-safe:transition-[opacity,scale] motion-safe:duration-(--nx-dur-quick) motion-safe:ease-out motion-safe:[transition-delay:calc(var(--step)*14ms)] [[data-nacre-motion=off]_&]:[transition-delay:0s] scale-50 opacity-0"></span>
</i>
</div>
<span data-part="trailing" class="shrink-0 text-body font-[500] whitespace-nowrap text-fg">5 left</span>
</div>/* The Tailwind theme lines Segmented progress uses. They come from nacre-theme.css (Resources, Tokens), which also defines
the --nx-* values these lines point at. Import that file once; this list is what this component needs from it. */
@theme inline {
--color-sunken: var(--nx-sunken);
--color-fg: var(--nx-fg);
--text-body: 0.875rem;
--text-body--line-height: 1.25rem;
--text-body--letter-spacing: 0em;
--text-body--font-weight: 400;
--spacing: 0.25rem;
--ease-out: cubic-bezier(.23, 1, .32, 1);
}
The Checkout flow audit has 24 screens. 19 cells are filled and the line after the track says 5 left; each screen audited fills the next cell.
A Brand panel row shows 21 of 24 cells for tokens in use and 3 unused at the end, so the gap is the story.
DoSet cells to the number of things being counted, up to about 24.
Don'tUse 100 cells to fake a percentage; use Progress.
DoSay what is counted in label, and put the remainder in trailing.
Don'tLeave the meaning to the colour alone.