Bytes
Format file sizes into human-readable strings.
formatBytes
Converts bytes to human-readable file sizes with automatic unit selection and locale-aware number formatting.
import { formatBytes } from "@tilt-legal/cubitt-components/utilities/formatters";
formatBytes(1024); // "1 KB"
formatBytes(1048576); // "1 MB"
formatBytes(1536, { decimals: 1 }); // "1.5 KB"
formatBytes(1024, { standard: "iec" }); // "1 KiB"| Property | Type | Default | Description |
|---|---|---|---|
decimals | number | 2 | Number of decimal places to display |
standard | 'jedec' | 'iec' | 'jedec' | Binary prefix standard (KB vs KiB) |
locale | string | 'en-AU' | Locale for number formatting |