Show a known amount of completed work with a bar or ring. Use an indeterminate state when the total is unknown.
Progress example
Example.jsx
import { signal } from "@fierst/aster";
import { Progress } from "./ui/progress";
import "./example.css";
export default function* Example() {
const completed = signal(2);
const total = 5;
for (;;)
yield (
<section class="sample">
<h2>Export issue proofs</h2>
<Progress value={completed()} max={total} label="Export progress" showValue />
<output>
{completed()} of {total} spreads exported
</output>
<button onClick={() => completed.set(completed() === total ? 0 : completed() + 1)}>
{completed() === total ? "Restart export" : "Export next spread"}
</button>
</section>
);
}
example.css
@media screen and (prefers-reduced-motion: no-preference) {
#example button:is(.v-primary, .v-secondary):enabled {
transition: transform 120ms ease-out;
}
#example button:is(.v-primary, .v-secondary):enabled:active {
transform: scale(0.98);
}
}
@media (prefers-reduced-motion: reduce) {
#example button:is(.v-primary, .v-secondary):enabled:active {
transition: none;
transform: none;
}
}
* {
box-sizing: border-box;
}
:root {
--example-seed: var(--aster-primary);
--example-secondary-text: var(--aster-on-surface-subtle);
}
body {
--aster-primary: color-mix(in srgb, var(--example-seed) 84%, var(--aster-on-surface));
--aster-on-surface-subtle: color-mix(in srgb, var(--example-secondary-text) 84%, var(--aster-on-surface));
--aster-input-border: color-mix(in srgb, var(--aster-on-surface) 55%, var(--aster-surface));
margin: 0;
padding: clamp(0.8rem, 4vw, 1.5rem);
color: var(--aster-on-surface);
background: var(--aster-surface-muted);
font: 1rem/1.5 var(--aster-font-sans);
}
#example {
display: grid;
gap: 0.8rem;
min-width: 0;
align-content: start;
}
#example > button,
.sample > button {
justify-self: start;
}
.sample,
.tile {
background: var(--aster-surface);
border: 1px solid var(--aster-border);
border-radius: var(--aster-radius-lg);
}
.sample {
display: grid;
gap: 0.8rem;
padding: clamp(0.85rem, 3vw, 1.35rem);
box-shadow: var(--aster-shadow-xs);
min-width: 0;
}
.tile {
padding: 1rem;
min-width: 0;
}
h2,
h3,
p,
dl,
ul {
margin-block: 0;
}
h2,
h3 {
letter-spacing: -0.025em;
line-height: 1.2;
}
h2 {
font-size: 1.25rem;
}
h3 {
font-size: 1rem;
}
.sample > header,
.identity > div,
.receipt {
display: grid;
gap: 0.25rem;
}
.sample > header p,
.tile p,
small {
color: var(--aster-on-surface-muted);
}
small {
font-size: 0.82rem;
}
.split,
.actions,
.identity {
display: flex;
align-items: center;
gap: 0.65rem;
flex-wrap: wrap;
}
.split {
justify-content: space-between;
padding-block: 0.4rem;
border-bottom: 1px solid var(--aster-border);
}
.split:last-child {
border-bottom: 0;
}
.metric {
font-size: 2rem;
letter-spacing: -0.06em;
}
.facts {
display: grid;
grid-template-columns: max-content 1fr;
gap: 0.45rem 1rem;
}
.facts dt {
color: var(--aster-on-surface-muted);
}
.facts dd {
margin: 0;
font-weight: 600;
}
.type-sample {
font:
2rem/1.2 Georgia,
serif;
}
.listing {
padding-inline-start: 1.25rem;
}
.ink-strip {
height: 1.2rem;
background: var(--aster-primary);
border-radius: var(--aster-radius-sm);
}
.ink-proof {
display: grid;
gap: 0.15rem;
border-left: 0.6rem solid;
padding-left: 0.8rem;
}
.ink-proof strong {
font-size: 1.25rem;
letter-spacing: 0.06em;
}
.glyph {
display: inline-grid;
place-items: center;
width: 2rem;
height: 2rem;
border-radius: var(--aster-radius-sm);
color: var(--aster-on-primary-subtle);
background: var(--aster-primary-subtle);
}
.cover-box {
width: min(100%, 18rem);
}
.cover {
display: flex;
min-height: 7.5rem;
height: 100%;
padding: 1rem 1.25rem;
flex-direction: column;
justify-content: space-between;
gap: 1.6rem;
color: #fff;
background: repeating-linear-gradient(150deg, transparent 0 8px, #fff2 8px 9px), #204a48;
}
.cover strong {
font:
italic 2.45rem/1 Georgia,
serif;
}
.cover span {
font: 0.78rem var(--aster-font-mono);
}
.cover.grove {
background-color: #3d4b27;
}
.cover.dune {
background-color: #7c4428;
}
button:not([class]),
.entry {
font: inherit;
font-size: 0.875rem;
padding: 0.45rem 0.8rem;
border: 1px solid var(--aster-border-strong);
border-radius: var(--aster-radius-control);
background: var(--aster-surface);
color: var(--aster-on-surface);
}
button:not([class]) {
cursor: pointer;
font-weight: 600;
}
button:not([class]):hover:enabled {
background: var(--aster-primary-subtle);
}
button:disabled {
cursor: default;
}
:focus-visible {
outline: 2px solid var(--aster-primary);
outline-offset: 3px;
}
output:not(:empty) {
display: block;
color: var(--aster-on-primary-subtle);
font-weight: 600;
font-size: 0.9rem;
}
Site-owned component source and scoped styles
src/ui/progress
import './theme.css';
import { scope } from '@fierst/aster';
const progScope = scope`
:scope {
display: grid;
gap: 0.35rem;
font-family: var(--aster-font-sans);
}
.prog-meta {
display: flex;
justify-content: space-between;
font-size: 0.82rem;
color: var(--aster-on-surface-variant);
}
.prog-val { font-family: var(--aster-font-mono); font-weight: 600; color: var(--aster-on-surface); }
.track {
position: relative;
height: 8px;
border-radius: var(--aster-radius-full);
background: var(--aster-primary-container);
overflow: hidden;
}
.fill {
height: 100%;
border-radius: var(--aster-radius-full);
background: var(--aster-primary);
transition: width var(--aster-dur-med) var(--aster-ease-spring);
}
.fill.is-indeterminate {
width: 38%;
animation: aster-indet 1.25s var(--aster-ease-standard) infinite;
}
@keyframes aster-indet {
0% { transform: translateX(-110%); }
100% { transform: translateX(300%); }
}
`;
export function Progress({
value,
max = 100,
label,
showValue = false,
class: extraClass,
}: {
value?: number;
max?: number;
label?: string;
showValue?: boolean;
class?: string;
}) {
max = Number.isFinite(max) && max > 0 ? max : 100;
const indeterminate = value === undefined || !Number.isFinite(value);
const current = indeterminate ? undefined : Math.max(0, Math.min(max, value));
const pct = ((current ?? 0) / max) * 100;
return (
<div class={[progScope, extraClass].filter(Boolean).join(' ')}>
{label || (showValue && !indeterminate) ? (
<div class="prog-meta">
<span>{label ?? ''}</span>
{showValue && !indeterminate ? <span class="prog-val">{Math.round(pct)}%</span> : null}
</div>
) : null}
<div
class="track"
role="progressbar"
aria-label={label ?? 'Progress'}
aria-valuemin={0}
aria-valuemax={max}
aria-valuenow={current}
>
<div
class="fill"
class:is-indeterminate={indeterminate}
style={indeterminate ? undefined : { width: `${pct}%` }}
/>
</div>
</div>
);
}
const ringScope = scope`
:scope {
position: relative;
display: inline-grid;
place-items: center;
}
svg { transform: rotate(-90deg); }
.bg-ring { stroke: var(--aster-primary-container); fill: none; }
.fg-ring {
stroke: var(--aster-primary);
fill: none;
stroke-linecap: round;
transition: stroke-dashoffset var(--aster-dur-med) var(--aster-ease-spring);
}
.ring-label {
position: absolute;
font-family: var(--aster-font-mono);
font-size: 0.74rem;
font-weight: 650;
color: var(--aster-on-surface);
}
`;
export function ProgressRing({
value,
size = 52,
strokeWidth = 5,
showLabel = true,
label = 'Progress',
class: extraClass,
}: {
value: number;
size?: number;
strokeWidth?: number;
showLabel?: boolean;
label?: string;
class?: string;
}) {
const clamped = Math.max(0, Math.min(100, Number.isFinite(value) ? value : 0));
const r = (size - strokeWidth) / 2;
const c = 2 * Math.PI * r;
const offset = c * (1 - clamped / 100);
return (
<div
aria-label={label}
class={[ringScope, extraClass].filter(Boolean).join(' ')}
role="progressbar"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={Math.round(clamped)}
style={{ width: `${size}px`, height: `${size}px` }}
>
<svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} aria-hidden="true">
<circle class="bg-ring" cx={size / 2} cy={size / 2} r={r} stroke-width={strokeWidth} />
<circle
class="fg-ring"
cx={size / 2}
cy={size / 2}
r={r}
stroke-width={strokeWidth}
stroke-dasharray={c}
stroke-dashoffset={offset}
/>
</svg>
{showLabel ? <span class="ring-label">{Math.round(clamped)}%</span> : null}
</div>
);
}
const skelScope = scope`
:scope {
display: block;
background: linear-gradient(
90deg,
var(--aster-surface-low) 25%,
var(--aster-surface-high) 50%,
var(--aster-surface-low) 75%
);
background-size: 200% 100%;
animation: aster-shimmer 1.4s ease-in-out infinite;
border-radius: var(--aster-radius-sm);
}
:scope.shape-circle { border-radius: var(--aster-radius-full); }
:scope.shape-pill { border-radius: var(--aster-radius-full); }
@keyframes aster-shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
`;
export function Skeleton({
width = '100%',
height = '1rem',
shape = 'rect',
class: extraClass,
}: {
width?: string;
height?: string;
shape?: 'rect' | 'pill' | 'circle';
class?: string;
}) {
return (
<span
aria-hidden="true"
class={[skelScope, shape !== 'rect' ? `shape-${shape}` : '', extraClass]
.filter(Boolean)
.join(' ')}
style={{ width, height }}
/>
);
}
Install
sh
npx @fierst/ui@1.0.2 add progressRegistry dependencies: theme.
Exports from ./ui/progress: Progress, ProgressRing, Skeleton.
Download the registry source for progress 1.0.2.
API contracts
ts
export function Progress({
value,
max = 100,
label,
showValue = false,
class: extraClass,
}: {
value?: number;
max?: number;
label?: string;
showValue?: boolean;
class?: string;
})
export function ProgressRing({
value,
size = 52,
strokeWidth = 5,
showLabel = true,
label = 'Progress',
class: extraClass,
}: {
value: number;
size?: number;
strokeWidth?: number;
showLabel?: boolean;
label?: string;
class?: string;
})
export function Skeleton({
width = '100%',
height = '1rem',
shape = 'rect',
class: extraClass,
}: {
width?: string;
height?: string;
shape?: 'rect' | 'pill' | 'circle';
class?: string;
})