Skip to content

Bytes

The Bytes component formats raw byte counts into human-readable file sizes (KB / MB / GB / TB). Supports both binary (1024) and decimal (1000) unit bases.

Basic Usage

Pass a byte value via the value prop. The component automatically selects the appropriate unit.

vue

<TBytes :value="128" />
<TBytes :value="2456000" />
<TBytes :value="1520000000" />

Decimal Places

Control decimal places via the decimals prop. Default is 1.

vue

<TBytes :value="1520000000" :decimals="0" />
<TBytes :value="1520000000" :decimals="2" />

Base Switching

Set :base="1000" for decimal units (commonly used by hard drive manufacturers). Default is 1024 (binary).

vue

<TBytes :value="1520000000" :base="1024" />
<TBytes :value="1520000000" :base="1000" />

IEC Units

Set iec to use KiB / MiB / GiB (IEC standard units, only effective with base=1024).

vue

<TBytes :value="1520000000" :base="1024" iec />

API

Props

PropDescriptionTypeDefault
valueByte countnumber— (required)
decimalsNumber of decimal placesnumber1
separatorSeparator between value and unitstring' '
baseUnit base (1024 binary / 1000 decimal)number1024
iecUse IEC standard units (KiB/MiB)booleanfalse