<div class="demo-caption">A countdown: the value goes down</div>
<div class="demo-row" style="align-items: center; gap: var(--ray-space-6)">
<ray-ring-progress id="demo-ring-timer" size="12rem" thickness="12" round-caps value="100" label="Round time left">
<div><div id="demo-ring-clock" style="font-size: 2.25em; font-weight: 600">3:00</div><div class="demo-muted" style="font-size: 0.5em">Round 4 / 12</div></div>
</ray-ring-progress>
<ray-stack gap="xs">
<ray-button id="demo-ring-go" size="sm" variant="light">Start</ray-button>
<p class="demo-muted" style="margin: 0">value from 100 to 0; the clock is the default slot.</p>
</ray-stack>
</div>
<div class="demo-caption">Sizes, colors and the percentage</div>
<div class="demo-row" style="align-items: center">
<ray-ring-progress size="xs" value="30"></ray-ring-progress>
<ray-ring-progress size="sm" value="45" color="teal" show-value></ray-ring-progress>
<ray-ring-progress size="md" value="60" color="violet" show-value round-caps></ray-ring-progress>
<ray-ring-progress size="lg" value="75" color="orange" thickness="6" show-value round-caps></ray-ring-progress>
<ray-ring-progress size="md" label="Loading"></ray-ring-progress>
</div>
<p class="demo-muted" style="margin: 0">Without <code>value</code> the arc spins (indeterminate).</p>
<div class="demo-caption">A goal: value of max</div>
<div class="demo-row" style="align-items: center">
<ray-ring-progress size="lg" value="6400" max="10000" color="green" round-caps label="Steps today">
<div><div style="font-weight: 600">6,400</div><div class="demo-muted" style="font-size: 0.6em">of 10,000 steps</div></div>
</ray-ring-progress>
</div>
<script type="module">
const ring = document.getElementById("demo-ring-timer");
const clock = document.getElementById("demo-ring-clock");
const go = document.getElementById("demo-ring-go");
const total = 180;
let left = total;
let timer = 0;
const paint = () => {
ring.value = (left / total) * 100;
clock.textContent = `${Math.floor(left / 60)}:${String(left % 60).padStart(2, "0")}`;
};
go.addEventListener("click", () => {
if (timer) {
clearInterval(timer);
timer = 0;
go.textContent = "Start";
return;
}
if (left === 0) left = total;
go.textContent = "Pause";
timer = setInterval(() => {
left = Math.max(0, left - 5);
paint();
if (left === 0) {
clearInterval(timer);
timer = 0;
go.textContent = "Start";
}
}, 250);
});
paint();
</script>
import type { CSSProperties } from "react";
import { RayRingProgress, RayStack, RayButton } from "@raylang/react";
export function RingProgressExample() {
return (
<>
<div className="demo-caption">A countdown: the value goes down</div>
<div className="demo-row" style={{ alignItems: "center", gap: "var(--ray-space-6)" } as CSSProperties}>
<RayRingProgress id="demo-ring-timer" size="12rem" thickness="12" roundCaps value={100} label="Round time left">
<div><div id="demo-ring-clock" style={{ fontSize: "2.25em", fontWeight: "600" }}>3:00</div><div className="demo-muted" style={{ fontSize: "0.5em" }}>Round 4 / 12</div></div>
</RayRingProgress>
<RayStack gap="xs">
<RayButton id="demo-ring-go" size="sm" variant="light">Start</RayButton>
<p className="demo-muted" style={{ margin: "0" }}>value from 100 to 0; the clock is the default slot.</p>
</RayStack>
</div>
<div className="demo-caption">Sizes, colors and the percentage</div>
<div className="demo-row" style={{ alignItems: "center" }}>
<RayRingProgress size="xs" value={30} />
<RayRingProgress size="sm" value={45} color="teal" showValue />
<RayRingProgress size="md" value={60} color="violet" showValue roundCaps />
<RayRingProgress size="lg" value={75} color="orange" thickness="6" showValue roundCaps />
<RayRingProgress size="md" label="Loading" />
</div>
<p className="demo-muted" style={{ margin: "0" }}>Without <code>value</code> the arc spins (indeterminate).</p>
<div className="demo-caption">A goal: value of max</div>
<div className="demo-row" style={{ alignItems: "center" }}>
<RayRingProgress size="lg" value={6400} max={10000} color="green" roundCaps label="Steps today">
<div><div style={{ fontWeight: "600" }}>6,400</div><div className="demo-muted" style={{ fontSize: "0.6em" }}>of 10,000 steps</div></div>
</RayRingProgress>
</div>
</>
);
}
<template>
<div class="demo-caption">A countdown: the value goes down</div>
<div class="demo-row" style="align-items: center; gap: var(--ray-space-6)">
<RayRingProgress id="demo-ring-timer" size="12rem" thickness="12" round-caps :value="100" label="Round time left">
<div><div id="demo-ring-clock" style="font-size: 2.25em; font-weight: 600">3:00</div><div class="demo-muted" style="font-size: 0.5em">Round 4 / 12</div></div>
</RayRingProgress>
<RayStack gap="xs">
<RayButton id="demo-ring-go" size="sm" variant="light">Start</RayButton>
<p class="demo-muted" style="margin: 0">value from 100 to 0; the clock is the default slot.</p>
</RayStack>
</div>
<div class="demo-caption">Sizes, colors and the percentage</div>
<div class="demo-row" style="align-items: center">
<RayRingProgress size="xs" :value="30" />
<RayRingProgress size="sm" :value="45" color="teal" show-value />
<RayRingProgress size="md" :value="60" color="violet" show-value round-caps />
<RayRingProgress size="lg" :value="75" color="orange" thickness="6" show-value round-caps />
<RayRingProgress size="md" label="Loading" />
</div>
<p class="demo-muted" style="margin: 0">Without <code>value</code> the arc spins (indeterminate).</p>
<div class="demo-caption">A goal: value of max</div>
<div class="demo-row" style="align-items: center">
<RayRingProgress size="lg" :value="6400" :max="10000" color="green" round-caps label="Steps today">
<div><div style="font-weight: 600">6,400</div><div class="demo-muted" style="font-size: 0.6em">of 10,000 steps</div></div>
</RayRingProgress>
</div>
</template>