UsageBar
Cuánto del límite de un plan se usa: «7,2 GB de 8 GB». Cerca del límite dice qué pasará y ofrece el siguiente paso antes de llegar.
import { UsageBar } from '@sypnia/ui/react'
En esta página
Los límites de un plan
Rows120.400 de 500.000
Emails this month10.000 de 10.000
Código
import { LinkButton, UsageBar, useSypnia } from '@sypnia/ui/react';
// The limits of a plan. Near the limit it says so and offers the next step.
export default function Plan() {
const { format } = useSypnia();
const gb = (v: number) => format.bytes(v * 1e9);
return (
<div className="sy-stack">
<UsageBar label="Rows" used={120_400} limit={500_000} />
<UsageBar label="Storage" used={7.2} limit={8} format={gb} action={<LinkButton href="#plans" size="sm">See larger plans</LinkButton>} />
<UsageBar label="Emails this month" used={10_000} limit={10_000} resetsAt="2026-12-01" action={<LinkButton href="#plans" size="sm" variant="primary">Move to Pro</LinkButton>} />
</div>
);
} Cuándo usarlo
Úsalo cuando
- Páginas de facturación y plan, y el resumen de un proyecto.
- Pasa
actioncon un enlace a los planes, yresetsAtpara límites mensuales.
No lo uses cuando
- Medidas sin un plan detrás: usa Meter.
Para todos
- Es un
meter; el aviso cerca del límite se dice en palabras.
Props
| UsageBar | Tipo | Por defecto |
|---|---|---|
labelobligatorio | ReactNode | |
limitobligatorio | number | |
usedobligatorio | number | |
actionThe next step, shown from 80 %: usually a LinkButton to the plans. | ReactNode | |
formatHow amounts are written: bytes, rows, requests. Defaults to a number. | ((v: number) => string) | |
loadingThe amount is on its way: the label stays, the amount and the bar are skeletons. Pass the last known `used` and `limit`, so the amount's bar is as long as its words will be. | boolean | |
resetsAtWhen the count starts again, for monthly limits. | string | number | Date |