Fmt
FmtFileSize
Converts byte counts to human-readable file size strings (KB, MB, GB, etc.).
Fmt
The Fmt category provides stateless display formatters. Each component is a thin wrapper around native Intl APIs, VueUse, or Nuxt utilities — they accept a raw value and render formatted output without any side effects.
Components
<XAFmtFileSize />
Converts a byte count to a human-readable string. Supports decimal (KB, MB, GB) or binary (KiB, MiB, GiB) unit systems.
<XAFmtFileSize :value="document.size" />
<!-- Output: 2.38 MB -->
<XAFmtFileSize :value="1073741824" :binary="true" :decimals="0" />
<!-- Output: 1 GiB -->
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | Number | required | File size in bytes |
decimals | Number | 2 | Decimal places |
binary | Boolean | false | Use binary units (KiB, MiB, GiB) |
locale | String | 'en-US' | BCP 47 locale for number formatting |
fallback | String | '0 B' | Text shown for zero or null values |
textClass | String | '' | Additional CSS classes |
AI Context
component: XAFmtFileSize
package: "@xenterprises/nuxt-x-app"
auto-import: true
prefix: XA
category: Fmt
use-when: Displaying raw byte counts as human-readable file sizes. Supports decimal (KB/MB/GB) and binary (KiB/MiB/GiB) unit systems. Stateless and purely presentational.
