Notificacionesprogresscircle
Circle Gauge
Indicador de progreso circular con porcentaje numérico central y animación suave.
Vista Previa en Vivo
35%
72%
Uso
Copia y pega este código directamente en tu componente React:
tsx
import { CircleProgress } from 'react-component-kit-ui/feedback';
<CircleProgress percent={72} size={110} color="#d4a017" />Instalación Manual
Si no estás usando el paquete npm, crea un archivo nuevo y pega el siguiente código: src/components/CircleProgress.tsx + CircleProgress.css:
CircleProgress.tsx
'use client';
import type { CSSProperties, HTMLAttributes } from 'react';
import './CircleProgress.css';
/**
* CircleProgress — A circular chart indicating a percentage of completion.
*
* @param percent - Required. 0–100.
* @param size - Optional. Diameter in px. Default 80.
* @param color - Optional. Default 'var(--c-primary, #6366f1)'.
* @param label - Optional. Accessible label. Default 'Progress'.
*/
export interface CircleProgressProps extends HTMLAttributes<HTMLDivElement> {
percent: number;
size?: number;
color?: string;
label?: string;
}
export function CircleProgress({
percent,
size = 80,
color = 'var(--c-primary, #6366f1)',
label = 'Progress',
className,
style,
...rest
}: CircleProgressProps) {
const clamped = Math.min(100, Math.max(0, percent));
const radius = size / 2 - 10;
const circum = 2 * Math.PI * radius;
const offset = circum - (clamped / 100) * circum;
return (
<div
{...rest}
role="progressbar"
aria-valuenow={clamped}
aria-valuemin={0}
aria-valuemax={100}
aria-label={label}
className={['circle-box', className].filter(Boolean).join(' ')}
style={{ '--gauge-size': `${size}px`, '--gauge-color': color, ...style } as CSSProperties}
>
<svg width={size} height={size} aria-hidden="true">
<circle className="circle-bg" cx={size / 2} cy={size / 2} r={radius} />
<circle className="circle-val" cx={size / 2} cy={size / 2} r={radius} strokeDasharray={circum} strokeDashoffset={offset} stroke={color} />
</svg>
<div className="circle-label" aria-hidden="true">{percent}%</div>
</div>
);
}
export default CircleProgress;CircleProgress.css
/* CircleProgress — ported from astro-component-kit (feedback/CircleProgress.astro) */
.circle-box {
position: relative;
width: var(--gauge-size);
height: var(--gauge-size);
display: grid; place-items: center;
}
svg { transform: rotate(-90deg); }
circle { fill: transparent; stroke-width: 6; stroke-linecap: round; }
.circle-bg {
stroke: var(--c-bg-elev, rgba(255,255,255,0.05));
stroke-width: 5;
}
.circle-val {
transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
filter: drop-shadow(0 0 3px var(--gauge-color));
}
.circle-label {
position: absolute;
font-size: 0.85rem;
font-weight: 800;
color: var(--c-text-1, #fff);
font-family: inherit;
}Información Rápida
- Categoría
- Notificaciones
- Nombre de archivo
CircleProgress.tsx- Dependencias
- Ninguna — React + CSS puro
- Etiquetas
- progresscircle