Documentation / Retours & superpositions
CircularProgress
Un indicateur de progression circulaire en SVG : déterminé (value de 0 à 100, bornée) ou indéterminé (indeterminate, l’anneau tourne), en cinq tailles, trois épaisseurs et six couleurs, avec le pourcentage ou n’importe quel contenu au centre.
Il porte role="progressbar" avec aria-valuenow (omis en mode indéterminé) : donnez-lui un aria-label qui dit ce qui progresse. Sans hook, il fonctionne aussi en composant serveur.
Exemples
Chargement indéterminé
Pour une attente dont on ne connaît pas la durée.
import { CircularProgress } from "@synertech/ui";
export function Indeterminate() {
return <CircularProgress indeterminate aria-label="Chargement des données" />;
}Valeur et pourcentage
showValue affiche la valeur arrondie au centre ; valueFormat la met en forme.
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>
);
}Tailles, épaisseurs et couleurs
size va de xs (24 px) à xl (96 px) ; thickness règle le trait, color la teinte.
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>
);
}Couleurs et contenu personnalisés
progressColor / trackColor prennent des classes stroke-* ; les enfants remplacent le pourcentage.
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>
);
}Progression d’un envoi
La valeur change au fil de l’eau ; la transition anime l’anneau (animated={false} la coupe).
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>
);
}Référence d’API
Composants
import { CircularProgress } from "@synertech/ui";Props — CircularProgressProps
| Prop | Type | Défaut | Description |
|---|---|---|---|
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 attributs natifs hérités de HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, gestionnaires d’événements…).
Types
type CircularProgressColor = | "default"
| "primary"
| "success"
| "warning"
| "error"
| "info"type CircularProgressSize = "xs" | "sm" | "md" | "lg" | "xl"type CircularProgressThickness = "thin" | "normal" | "thick"