Skip to content
Nana UI

Format Bytes

View .md Download

Formats a byte (or bit) value into a human-readable, locale-aware string, auto-scaling to the best unit (B → kB → MB → GB …).

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/format-bytes";
<nana-format-bytes value="1048576"></nana-format-bytes>

Properties

PropertyAttributeTypeDefaultDescription
display'long' | 'short' | 'narrow''short'How verbose the unit label is
localestring | undefinedBCP 47 locale (defaults to the document locale)
unit'byte' | 'bit''byte'Base unit
valuenumber0The value to format
Explore Format Bytes interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook