Component

DataBytes

Published on

Description anchor

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 anchor

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 anchor

  • 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 anchor

None