Skip to content

Bytes

<quiet-bytes> stable since 1.0

Formats an arbitrary number of bytes or bits into a human-readable size.

<quiet-bytes value="240000000"></quiet-bytes>

Examples Jump to heading

Formatting bytes Jump to heading

Set the value attribute to indicate the number of bytes to format.

<quiet-bytes value="68000"></quiet-bytes>

Formatting bits Jump to heading

Set the unit attribute to bit to output bits instead of bytes.

<quiet-bytes value="42000000000" unit="bit"></quiet-bytes>

Localizing output Jump to heading

Use the lang attribute to format the output in a different locale.




<quiet-bytes value="12300000" lang="en"></quiet-bytes><br>
<quiet-bytes value="12300000" lang="es"></quiet-bytes><br>
<quiet-bytes value="12300000" lang="de"></quiet-bytes><br>
<quiet-bytes value="12300000" lang="ru"></quiet-bytes>

API Jump to heading

Importing Jump to heading

The autoloader is the recommended way to import components but, if you prefer to do it manually, the following code snippets will be helpful.

CDN Self-hosted

To manually import <quiet-bytes> from the CDN, use the following code.

import 'https://cdn.quietui.org/v2.0.0/components/bytes/bytes.js';

To manually import <quiet-bytes> from a self-hosted distribution, use the following code. Remember to replace /path/to/quiet with the appropriate local path.

import '/path/to/quiet/components/bytes/bytes.js';

Properties Jump to heading

Bytes has the following properties that can be set with corresponding attributes. In many cases, the attribute's name is the same as the property's name. If an attribute is different, it will be displayed after the property. Learn more about attributes and properties

Property / Attribute Description Reflects Type Default
value The number of bytes to format. number 0
unit The unit to display. 'byte'
'bit'
'byte'
display How to display the bytes, e.g. "100 bytes", "100 b", or "100b". 'long'
'short'
'narrow'
'narrow'
Search this website Toggle dark mode View the code on GitHub Follow @quietui.org on Bluesky Follow @quiet_ui on X

    No results found