Components
Circular Progress
An SVG ring indicator with an optional percentage label.
Installation
$ npx veil-ui@latest add circular-progressUsage
import { CircularProgress } from "@/components/ui/circular-progress";
<CircularProgress value={72} showValue aria-label="Upload progress" />;Examples
Basic
65%
Sizes
50%
80%
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | — | Completion from 0 to 100. |
| size | number | 48 | Diameter in pixels. |
| strokeWidth | number | 4 | Ring thickness in pixels. |
| showValue | boolean | false | Shows the rounded percentage in the center. |
| label | string | "Progress" | Accessible name for the progressbar. |
Accessibility
- Exposes
role="progressbar"witharia-valuemin,aria-valuemaxandaria-valuenow. - The SVG and percentage text are hidden from screen readers, which read the numeric value instead.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add circular-progress --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed } from "vue";
import { cn } from "@/lib/utils";
import type { CircularProgressProps } from "./types";
const props = withDefaults(defineProps<CircularProgressProps>(), {
size: 48,
strokeWidth: 4,
showValue: false,
label: "Progress",
});
const clamped = computed(() => Math.min(100, Math.max(0, props.value)));
const radius = computed(() => (props.size - props.strokeWidth) / 2);
const circumference = computed(() => 2 * Math.PI * radius.value);
const offset = computed(
() => circumference.value - (clamped.value / 100) * circumference.value,
);
</script>
<template>
<div
data-slot="circular-progress"
role="progressbar"
:aria-label="label"
:aria-valuemin="0"
:aria-valuemax="100"
:aria-valuenow="Math.round(clamped)"
:class="cn('relative inline-flex items-center justify-center', props.class)"
:style="{ width: `${size}px`, height: `${size}px` }"
>
<svg :width="size" :height="size" class="-rotate-90" aria-hidden="true">
<circle
:cx="size / 2"
:cy="size / 2"
:r="radius"
fill="none"
:stroke-width="strokeWidth"
class="stroke-muted"
/>
<circle
:cx="size / 2"
:cy="size / 2"
:r="radius"
fill="none"
:stroke-width="strokeWidth"
stroke-linecap="round"
:stroke-dasharray="circumference"
:stroke-dashoffset="offset"
class="stroke-primary transition-[stroke-dashoffset]"
/>
</svg>
<span v-if="showValue" class="absolute text-xs font-medium">
{{ Math.round(clamped) }}%
</span>
</div>
</template>