Format Bytes
<ahi-format-bytes> | AhiFormatBytes
Formats a number as a human readable bytes value.
Examples
Formatting bytes
Set the value attribute to a number to get the value in bytes.
<ahi-format-bytes value="42"></ahi-format-bytes><br />
<ahi-format-bytes value="4200"></ahi-format-bytes><br />
<ahi-format-bytes value="4200000"></ahi-format-bytes><br />
<ahi-format-bytes value="4200000000"></ahi-format-bytes>
Formatting bits
To get the value in bits, set the unit attribute to bit.
<ahi-format-bytes value="42" unit="bit"></ahi-format-bytes><br />
<ahi-format-bytes value="4200" unit="bit"></ahi-format-bytes><br />
<ahi-format-bytes value="4200000" unit="bit"></ahi-format-bytes><br />
<ahi-format-bytes value="4200000000" unit="bit"></ahi-format-bytes>
Importing
To import this component using a script tag:
<script type="module" src="/path/to/azalea-kit-ui/dist/components/format-bytes/format-bytes.js"></script>
To import this component using a bundler:
import '@azaleahealth/azalea-kit-ui/dist/components/format-bytes/format-bytes.js';
Properties
| Name | Description | Type | Default | |
|---|---|---|---|---|
value
|
The number to format in bytes. |
number
|
0
|
|
unit
|
The type of unit to display. |
'byte' | 'bit'
|
'byte'
|
|
display
|
Determines how to display the result, e.g. “100 bytes”, “100 b”, or “100b”. |
'long' | 'short' | 'narrow'
|
'short'
|
|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Learn more about properties and attributes.