Synertech Web/ui v0.57.5 Site Storybook

Documentation / Feedback & overlays

CircularProgress

Server-compatible@synertech/uiOpen in Storybook

A circular SVG progress indicator: determinate (value from 0 to 100, clamped) or indeterminate (indeterminate, the ring spins), in five sizes, three thicknesses and six colours, with the percentage or any content in the centre.

It carries role="progressbar" with aria-valuenow (omitted in indeterminate mode): give it an aria-label that says what is progressing. With no hooks, it also works as a server component.

Examples

Indeterminate loading

For a wait whose duration is unknown.

Open in a tab
import { CircularProgress } from "@synertech/ui";

export function Indeterminate() {
  return <CircularProgress indeterminate aria-label="Chargement des données" />;
}

Value and percentage

showValue shows the rounded value in the centre; valueFormat formats it.

Open in a tab
import { CircularProgress } from "@synertech/ui";

export function WithValue() {
  return (
    <div className="flex items-center gap-6">
      <CircularProgress value={35} showValue size="lg" aria-label="Import" />
      <CircularProgress
        value={72}
        showValue
        size="lg"
        valueFormat={(value) => `${value} / 100`}
        aria-label="Score"
      />
    </div>
  );
}

Sizes, thicknesses and colours

size goes from xs (24 px) to xl (96 px); thickness sets the stroke, color the hue.

Open in a tab
import { CircularProgress } from "@synertech/ui";

export function Appearance() {
  return (
    <div className="flex items-center gap-4">
      <CircularProgress value={60} size="xs" thickness="thin" color="default" aria-label="xs" />
      <CircularProgress value={60} size="sm" color="info" aria-label="sm" />
      <CircularProgress value={60} size="md" color="success" aria-label="md" />
      <CircularProgress value={60} size="lg" thickness="thick" color="warning" aria-label="lg" />
      <CircularProgress value={60} size="xl" thickness="thick" color="error" aria-label="xl" />
    </div>
  );
}

Custom colours and content

progressColor / trackColor take stroke-* classes; children replace the percentage.

Open in a tab
import { CircularProgress } from "@synertech/ui";

export function CustomContent() {
  return (
    <CircularProgress
      value={80}
      size="xl"
      thickness="thick"
      progressColor="stroke-violet-600"
      trackColor="stroke-violet-100"
      aria-label="Objectif mensuel"
    >
      <div className="text-center leading-tight">
        <div className="text-lg font-bold text-violet-700">8/10</div>
        <div className="text-[10px] text-gray-500">ventes</div>
      </div>
    </CircularProgress>
  );
}

Upload progress

The value changes as it goes; the transition animates the ring (animated={false} turns it off).

Open in a tab
import { useEffect, useState } from "react";
import { CircularProgress } from "@synertech/ui";

export function Upload() {
  const [progress, setProgress] = useState(0);

  useEffect(() => {
    const timer = setInterval(() => setProgress((value) => (value >= 100 ? 0 : value + 10)), 600);
    return () => clearInterval(timer);
  }, []);

  return (
    <div className="flex items-center gap-3">
      <CircularProgress
        value={progress}
        showValue
        color={progress === 100 ? "success" : "primary"}
        aria-label="Envoi de photo.jpg"
      />
      <span className="text-sm text-gray-600">
        {progress === 100 ? "Envoi terminé" : "Envoi de photo.jpg…"}
      </span>
    </div>
  );
}

API reference

Components

CircularProgress

ComponentServer-compatible
import { CircularProgress } from "@synertech/ui";

Props — CircularProgressProps

PropTypeDefaultDescription
animated boolean true
children ReactNode —
color CircularProgressColor "primary"
indeterminate boolean false
progressColor string —
showValue boolean false
size CircularProgressSize "md"
thickness CircularProgressThickness "normal"
trackColor string —
value number 0
valueFormat (value: number) => string —

+ 277 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).

Types

type CircularProgressColor = | "default"
  | "primary"
  | "success"
  | "warning"
  | "error"
  | "info"
type CircularProgressSize = "xs" | "sm" | "md" | "lg" | "xl"
type CircularProgressThickness = "thin" | "normal" | "thick"