Bedform UILoading & Progress
Progress Ring
Show determinate progress.
Progress Ring
*
string
*
number
*
number
*
number
Usage
import { ProgressRing } from "@bedform/ui/progress-ring";
import type { CSSProperties } from "react";
export function WorldGeneration() {
return (
<ProgressRing
style={{ "--ore-progress-ring-frame": 6 } as CSSProperties}
role="progressbar"
aria-label="World generation progress"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={40}
/>
);
}Size and color
Progress Ring uses the current font size and text color.
<span style={{ fontSize: "2rem", color: "#52A535" }}>
<ProgressRing
style={{ "--ore-progress-ring-frame": 6 } as CSSProperties}
role="progressbar"
aria-label="World generation progress"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={40}
/>
</span>Value and maximum value
Set --ore-progress-ring-frame from 0 through 15, and expose the underlying value with standard progressbar ARIA attributes. For a value and maximum, calculate the frame:
function ChunkProgress({ loaded, total }: { loaded: number; total: number }) {
const frame = Math.min(
15,
Math.floor((Math.min(Math.max(loaded, 0), total) / total) * 16),
);
return (
<ProgressRing
style={{ "--ore-progress-ring-frame": frame } as CSSProperties}
role="progressbar"
aria-label="Chunks loaded"
aria-valuemin={0}
aria-valuemax={total}
aria-valuenow={loaded}
/>
);
}The SVG contains 16 frames. The normalized progress is split into equal 6.25% ranges: frame 0 represents [0%, 6.25%), frame 1 represents [6.25%, 12.5%), ... , and frame 15 represents [93.75%, 100%].
CSS variables
| Variable | Purpose |
|---|---|
--ore-progress-ring-frame | Sprite frame from 0 through 15 |
Accessibility
Progress Ring is visual-only CSS. Add role="progressbar", aria-valuemin, aria-valuemax, and aria-valuenow, then give it an accessible name with aria-label or aria-labelledby. Update the frame and ARIA value together when progress changes.