Progress Donut
Displays an indicator showing the completion progress of a task as a circular progress bar.
The indicator color is inherited via currentColor
. Override the default (accent-600
) by setting theProgressDonutIndicator
's text color.
import { ProgressDonut, ProgressDonutIndicator } from "@ngrok/mantle/progress";
<ProgressDonut value={60} className="size-10" strokeWidth="0.375rem">
<ProgressDonutIndicator />
</ProgressDonut>
<ProgressDonut value={60} className="size-10" strokeWidth="0.375rem">
<ProgressDonutIndicator className="text-fuchsia-600" />
</ProgressDonut>
<div className="flex flex-col gap-2">
<div className="flex items-center gap-1.5 text-sm">
<ProgressDonut value={100} className="size-6">
<ProgressDonutIndicator />
</ProgressDonut>
Data transfer out
</div>
<div className="flex items-center gap-1.5 text-xs">
<div className="grid w-6 place-items-center">
<ProgressDonut value={100} className="size-4" strokeWidth="0.1875rem">
<ProgressDonutIndicator />
</ProgressDonut>
</div>
Included
</div>
<div className="flex items-center gap-1.5 text-xs">
<div className="grid w-6 place-items-center">
<ProgressDonut value={25} className="size-4" strokeWidth="0.1875rem">
<ProgressDonutIndicator className="text-success-600" />
</ProgressDonut>
</div>
Additional
</div>
</div>
Indeterminate Value
You can set the value
prop to "indeterminate"
to show the progress bar in an indeterminate state.
import { ProgressDonut, ProgressDonutIndicator } from "@ngrok/mantle/progress";
<ProgressDonut className="size-10" value="indeterminate" strokeWidth="0.375rem">
<ProgressDonutIndicator />
</ProgressDonut>
Dynamic Colors
The color of the ProgressDonutIndicator
is inherited from the parent text color using currentColor
. Using this, you can easily change the color of it based on the current progress value.
import { ProgressDonut, ProgressDonutIndicator } from "@ngrok/mantle/progress";
const Example = () => {
const [value, setValue] = useState(0);
function computeColor() {
switch (true) {
case value <= 20:
return "text-accent-600";
case value <= 40:
return "text-success-600";
case value <= 60:
return "text-warning-600";
case value <= 80:
return "text-fuchsia-600";
default:
return "text-danger-600";
}
};
return (
<form className="space-y-4">
<ProgressDonut value={value} className="size-10" strokeWidth="0.375rem">
<ProgressDonutIndicator className={computeColor()} />
</ProgressDonut>
<label className="block space-y-1">
<p>Value:</p>
<input type="range" min={0} max={100} value={value} onChange={(e) => setValue(Number(e.target.value))} /> (
{value}%)
</label>
</form>
);
};
API Reference
ProgressDonut
A simple circular progress bar which shows the completion progress of a task.
The indicator color is inherited via currentColor
. Override the default (accent-600
) by setting theProgressDonutIndicator
's text color.
The ProgressDonut
accepts the following props in addition to the standard HTML svg attributes.
ProgressDonutIndicator
The indicator for the circular progress bar.
All props from svg g.