Veil UI
Components

Circular Progress

An SVG ring indicator with an optional percentage label.

Installation

$ npx veil-ui@latest add circular-progress

Usage

import { CircularProgress } from "@/components/ui/circular-progress";

<CircularProgress value={72} showValue aria-label="Upload progress" />;

Examples

Basic

65%

Sizes

50%
80%

API reference

PropTypeDefaultDescription
valuenumber—Completion from 0 to 100.
sizenumber48Diameter in pixels.
strokeWidthnumber4Ring thickness in pixels.
showValuebooleanfalseShows the rounded percentage in the center.
labelstring"Progress"Accessible name for the progressbar.

Accessibility

  • Exposes role="progressbar" with aria-valuemin, aria-valuemax and aria-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>

On this page