Skip to content
Nana UI

Formatters

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 …).

View .md Download
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/format-bytes";
<nana-format-bytes value="1048576"></nana-format-bytes>

Properties

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