Bytes
A size in bytes, in the unit that reads best: 512 B, 1.4 MB, 3 GB. The exact count is on hover.
import { Bytes, ValueSkeleton } from '@sypnia/ui/react'
Storage by table
| Table | Size |
|---|---|
orders | 2.4 MB |
products | 180 kB |
events | 3 GB |
settings | 812 B |
Code
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
Code
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>
);
} When to use it
Use it when
- Storage, uploads, payloads.
Do not use it when
- Speeds or rates: write the unit with Number.
For everyone
- The unit is written in the person's language.
Props
| Bytes | Type | Default |
|---|---|---|
valuerequired | number | null | undefined |
| ValueSkeleton | Type | Default |
|---|---|---|
chars | number | 6 |