Formats a byte count as localized, human-readable decimal or binary units.
<div nve-layout="column gap:sm">
<nve-format-bytes>1024</nve-format-bytes>
<nve-format-bytes>1048576</nve-format-bytes>
<nve-format-bytes>1073741824</nve-format-bytes>
</div>
<div nve-layout="column gap:sm">
<nve-format-bytes>1024</nve-format-bytes>
<nve-format-bytes>1048576</nve-format-bytes>
<nve-format-bytes>1073741824</nve-format-bytes>
</div>
Installation
<script type="module">
import '@nvidia-elements/core/format-bytes/define.js';
</script>
<div nve-layout="column gap:sm">
<nve-format-bytes>1024</nve-format-bytes>
<nve-format-bytes>1048576</nve-format-bytes>
<nve-format-bytes>1073741824</nve-format-bytes>
</div>
<script type="module">
import '@nvidia-elements/core/format-bytes/define.js';
</script>
<div nve-layout="column gap:sm">
<nve-format-bytes>1024</nve-format-bytes>
<nve-format-bytes>1048576</nve-format-bytes>
<nve-format-bytes>1073741824</nve-format-bytes>
</div>
nve api.get nve-format-bytes
nve api.get nve-format-bytes
Format Bytes converts byte counts into readable decimal or binary units. Supply the byte count as text content to provide an SSR fallback, or set the value property or attribute for JavaScript and bound data. If both are present, value takes precedence.
The locale property controls number formatting. Unit labels remain lowercase English strings in every locale.
Default
Automatic decimal conversion for concise file sizes and storage metrics. The component selects the appropriate unit from the byte count.
<div nve-layout="column gap:sm">
<nve-format-bytes>1024</nve-format-bytes>
<nve-format-bytes>1048576</nve-format-bytes>
<nve-format-bytes>1073741824</nve-format-bytes>
</div>
<div nve-layout="column gap:sm">
<nve-format-bytes>1024</nve-format-bytes>
<nve-format-bytes>1048576</nve-format-bytes>
<nve-format-bytes>1073741824</nve-format-bytes>
</div>
Unit
Forced unit magnitudes for comparing byte counts on a consistent scale. Use when values need the same unit across a table or chart.
<div nve-layout="column gap:sm">
<nve-format-bytes unit="kb">1048576</nve-format-bytes>
<nve-format-bytes unit="mb">1048576</nve-format-bytes>
<nve-format-bytes unit="gb">1048576</nve-format-bytes>
</div>
<div nve-layout="column gap:sm">
<nve-format-bytes unit="kb">1048576</nve-format-bytes>
<nve-format-bytes unit="mb">1048576</nve-format-bytes>
<nve-format-bytes unit="gb">1048576</nve-format-bytes>
</div>
Unit Display
Short and long unit labels for compact metrics or explanatory text. Long labels improve clarity when space allows.
<div nve-layout="column gap:sm">
<nve-format-bytes unit-display="short">1048576</nve-format-bytes>
<nve-format-bytes unit-display="long">1048576</nve-format-bytes>
<nve-format-bytes display="binary" unit-display="long">1048576</nve-format-bytes>
</div>
<div nve-layout="column gap:sm">
<nve-format-bytes unit-display="short">1048576</nve-format-bytes>
<nve-format-bytes unit-display="long">1048576</nve-format-bytes>
<nve-format-bytes display="binary" unit-display="long">1048576</nve-format-bytes>
</div>
Precision
Fraction digit controls for matching the precision of storage measurements. Use fixed digits when values must align visually.
<div nve-layout="column gap:sm">
<nve-format-bytes maximum-fraction-digits="0">1234567</nve-format-bytes>
<nve-format-bytes maximum-fraction-digits="2">1234567</nve-format-bytes>
<nve-format-bytes minimum-fraction-digits="3" maximum-fraction-digits="3">1234567</nve-format-bytes>
</div>
<div nve-layout="column gap:sm">
<nve-format-bytes maximum-fraction-digits="0">1234567</nve-format-bytes>
<nve-format-bytes maximum-fraction-digits="2">1234567</nve-format-bytes>
<nve-format-bytes minimum-fraction-digits="3" maximum-fraction-digits="3">1234567</nve-format-bytes>
</div>
Locale
Explicit locale formatting for audiences whose numeric separators differ from the document language. Unit labels remain lowercase English.
<div nve-layout="column gap:sm">
<nve-format-bytes locale="en-US">1048576</nve-format-bytes>
<nve-format-bytes locale="de-DE">1048576</nve-format-bytes>
<nve-format-bytes locale="fr-FR">1048576</nve-format-bytes>
</div>
<div nve-layout="column gap:sm">
<nve-format-bytes locale="en-US">1048576</nve-format-bytes>
<nve-format-bytes locale="de-DE">1048576</nve-format-bytes>
<nve-format-bytes locale="fr-FR">1048576</nve-format-bytes>
</div>
Value
Value attribute input for JavaScript or bound data. It takes precedence over text content while the text remains an SSR fallback.
<nve-format-bytes value="1048576">1024</nve-format-bytes>
<nve-format-bytes value="1048576">1024</nve-format-bytes>
1024
Display
Decimal and binary conversion for matching SI or IEC storage conventions. Use the convention expected by the surrounding product.
<div nve-layout="column gap:sm">
<nve-format-bytes display="decimal">1024</nve-format-bytes>
<nve-format-bytes display="binary">1024</nve-format-bytes>
</div>
<div nve-layout="column gap:sm">
<nve-format-bytes display="decimal">1024</nve-format-bytes>
<nve-format-bytes display="binary">1024</nve-format-bytes>
</div>
Release Status
All elements and features go through 3 phases of stability, pre-release, beta and stable.
pre-release Docs Preview API Documentation Fully Themeable
beta Robust unit test coverages Passed API Review Passed Designer VQA Review Included in library package stable No known outstanding AA WCAG issues No known outstanding performance issues Adapts to different screen/container sizes No breaking API changes for at least 90 days