Bytes
Un tamaño en bytes, en la unidad que mejor se lee: 512 B, 1,4 MB, 3 GB. La cantidad exacta aparece al pasar el puntero.
import { Bytes, ValueSkeleton } from '@sypnia/ui/react'
Almacenamiento por tabla
| Table | Size |
|---|---|
orders | 2,4 MB |
products | 180 kB |
events | 3 GB |
settings | 812 B |
Código
import { Bytes, Table } from '@sypnia/ui/react';
// The unit that reads best for each size; the exact bytes are on hover.
const tables = [
{ name: 'orders', size: 2_516_582 }, { name: 'products', size: 184_320 }, { name: 'events', size: 3_221_225_472 }, { name: 'settings', size: 812 },
];
export default function Sizes() {
return <Table label="Storage by table" rows={tables} rowKey={(t) => t.name}
columns={[{ id: 'name', header: 'Table', cell: (t) => <code>{t.name}</code> }, { id: 'size', header: 'Size', numeric: true, cell: (t) => <Bytes value={t.size} /> }]} />;
} Skeleton
2,4 MB
Código
import { Bytes, ValueSkeleton } from '@sypnia/ui/react';
// A size and its skeleton.
export default function Skeleton() {
return (
<div className="sy-cols sy-cols--stack">
<span><Bytes value={2516582} /></span>
<span><ValueSkeleton chars={6} /></span>
</div>
);
} Cuándo usarlo
Úsalo cuando
- Almacenamiento, archivos subidos, cuerpos de peticiones.
No lo uses cuando
- Velocidades o tasas: escribe la unidad con Number.
Para todos
- La unidad se escribe en el idioma de la persona.
Props
| Bytes | Tipo | Por defecto |
|---|---|---|
valueobligatorio | number | null | undefined |
| ValueSkeleton | Tipo | Por defecto |
|---|---|---|
chars | number | 6 |