glasscn
ShowcaseDocsComponentsStudioThemingNative
5Get started
Guides
IntroductionInstallationThemingFonts & typeStudioReact Native
Surfaces
AuroraBackdropGlassLiquid glassCardTheme scopeBackground extensionScroll areaAccordionCollapsibleAlertItemEmpty
Typography
TypographyProse
Controls
ButtonBadgeInputTextareaLabelSwitchCheckboxSegmented controlTabsGlass groupGlass clusterGlass morphSliderProgressKbdSeparatorAvatarGlass preferencesComboboxCalendarDate pickerSpinnerSkeletonSelectRadio groupFieldInput groupButton groupToggleToggle groupStepper
Overlays
DialogAlert dialogSheetAction sheetPopoverTooltipDropdown menuToasterCommandDrawerContext menuConfirmation popover
Navigation
DockToolbarScroll edgeNavigation barSidebarSearch fieldGrouped list
Data
Activity ringsProgress ringSparklineStatKPIWidgetRange chartBar listGaugeTrackerCategory barHeatmapChartArea chartBar chartLine chartDonut chartTableData table
Chat
ChatChat markdownChat parts
Blocks
More Apple glass examplesLiquid Glass examplesDashboardAnalyticsSettingsSign inChat
glasscn — a shadcn registry. Copy it, own it, change it.DocsThemingregistry.json
Data

Progress ring

One ring that closes around its content — a goal, a countdown, a seal.

Installation

pnpm dlx shadcn@latest add https://glasscn.app/r/progress-ring.json

React Native (iOS, Android and web through react-native-web) — same parts and props:

pnpm dlx shadcn@latest add https://glasscn.app/r/native-progress-ring.json

Or with the namespace set up: shadcn add @glasscn-app/progress-ring

Props

PropTypeDefault
valuenumber

0–1.

—
sizenumber72
colorstring

Ring and content colour.

"var(--primary)"

Source

components/glass/progress-ring.tsx
import * as React from "react"
import { cn } from "@/lib/glass-cn"

import { drawEase, glassTime, ringArc } from "@/lib/glass-charts"

/**
 * One ring that closes around its content — a goal, a countdown, a seal.
 * `value` 0–1; the arc draws in on mount.
 */
function ProgressRing({
  value,
  size = 72,
  stroke,
  color = "var(--primary)",
  className,
  children,
  ...props
}: React.ComponentProps<"div"> & { value: number; size?: number; stroke?: number; color?: string }) {
  const sw = stroke ?? Math.max(3, size * 0.075)
  const r = size / 2 - sw / 2
  const { circumference, offset } = ringArc(r, Math.min(1, value))
  const percent = Math.round(Math.min(1, Math.max(0, value)) * 100)
  return (
    <div
      data-slot="progress-ring"
      role="progressbar"
      aria-valuemin={0}
      aria-valuemax={100}
      aria-valuenow={percent}
      // named by default; pass aria-label (or aria-labelledby) to say what it measures
      aria-label={props["aria-labelledby"] ? undefined : `Progress ${percent}%`}
      className={cn("relative inline-flex shrink-0 items-center justify-center", className)}
      style={{ width: size, height: size }}
      {...props}
    >
      <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} className="absolute inset-0 -rotate-90" aria-hidden>
        <circle cx={size / 2} cy={size / 2} r={r} fill={`color-mix(in oklch, ${color} 12%, transparent)`} stroke={color} strokeOpacity={0.2} strokeWidth={sw} />
        <circle
          cx={size / 2}
          cy={size / 2}
          r={r}
          fill="none"
          stroke={color}
          strokeWidth={sw}
          strokeLinecap="round"
          strokeDasharray={`${circumference} ${circumference}`}
          strokeDashoffset={offset}
          data-glass-motion
          style={{
            ["--glass-draw-from" as string]: `${circumference}`,
            animation: `glass-draw ${glassTime(5)} ${drawEase} both`,
            transition: `stroke-dashoffset ${glassTime(4)} ${drawEase}`,
          }}
        />
      </svg>
      <div data-slot="progress-ring-content" className="relative flex items-center justify-center text-center type-glass-display" style={{ color }}>
        {children}
      </div>
    </div>
  )
}

export { ProgressRing }
Activity ringsSparkline
64%
3/10