Skip to content

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'

On this page
  1. Storage by table
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

Storage by table

TableSize
orders2.4 MB
products180 kB
events3 GB
settings812 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

BytesTypeDefault
valuerequired number | null | undefined
ValueSkeletonTypeDefault
chars number 6
  1. Storage by table
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms