Format Bytes
Formats a byte (or bit) value into a human-readable, locale-aware string, auto-scaling to the best unit (B → kB → MB → GB …).
Preview
Section titled “Preview”<nana-format-bytes value="1048576"></nana-format-bytes> Installation
Section titled “Installation”npm install @nana-tec/ui-componentsImport
Section titled “Import”import "@nana-tec/ui-components/format-bytes";Basic usage
Section titled “Basic usage”<nana-format-bytes value="1048576"></nana-format-bytes>Examples
Section titled “Examples”<nana-format-bytes value="1024"></nana-format-bytes>
<nana-format-bytes value="1048576"></nana-format-bytes>
<nana-format-bytes value="1500000" unit="bit"></nana-format-bytes> Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
display | — | 'long' | 'short' | 'narrow' | 'short' | How verbose the unit label is |
locale | — | string | undefined | — | BCP 47 locale (defaults to the document locale) |
unit | — | 'byte' | 'bit' | 'byte' | Base unit |
value | — | number | 0 | The value to format |
Related components
Section titled “Related components”Storybook
Section titled “Storybook” Explore Format Bytes interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook