Component

DataBytes

Published on

Description Link to section description

The DataBytes component formats a raw byte value into a human-readable file size string (e.g. KB, MB, GB) using Intl.NumberFormat for locale-aware formatting.

Use DataBytes when displaying file sizes, storage quotas, or transfer amounts. For plain numbers without unit conversion, use DataNumber.

Example Link to section example

Open in new tab(opens in new tab)
View HTML markup
<p><data value="0">0 Bytes</data></p>
<p><data value="1024">1 KB</data></p>
<p><data value="1048576">1 MB</data></p>
<p><data value="1073741824">1 GB</data></p>
<p><data value="1099511627776">1 TB</data></p>

Accessibility Link to section accessibility

  • Renders as a <data> element with the raw byte value preserved in the value attribute
  • Screen readers announce the formatted text content
  • Locale-aware formatting respects the user's language preferences

Variables Link to section variables

None