Components
Format
Format, dressed in the paper-and-ink system: Intl formatting for numbers, currency, bytes and relative time. The parts — Number, Byte, Time, RelativeTime.
#Basic usage
12,345.671.54 MB09:308 months ago
<script setup lang="ts">
import { Format } from "@bysages/vue";
// A fixed past date, not Date.now() — the relative time resolves against
// the machine clock, and a server/client instant far from a unit boundary
// hydrates to the same words.
const released = new Date(2026, 0, 15);
</script>
<template>
<div class="flex gap-6">
<Format.Number :value="12345.67" />
<Format.Byte :value="1536000" />
<Format.Time :value="new Date(2026, 4, 4, 9, 30)" />
<Format.RelativeTime :value="released" />
</div>
</template>
#Props
#Byte
| Prop | Type | Default | Description |
|---|---|---|---|
unit | 'bit' | 'byte' | The unit granularity to display | |
unitDisplay | 'long' | 'short' | 'narrow' | The unit display | |
unitSystem | 'decimal' | 'binary' | The unit system to use for formatting | |
value | number | The byte size to format |
#Number
| Prop | Type | Default | Description |
|---|---|---|---|
compactDisplay | 'short' | 'long' | undefined | — | |
currencyDisplay | string | undefined | — | |
currencySign | string | undefined | — | |
notation | 'standard' | 'scientific' | 'engineering' | 'compact' | undefined | — | |
signDisplay | 'auto' | 'never' | 'always' | 'exceptZero' | undefined | — | |
unit | string | undefined | — | |
unitDisplay | 'short' | 'long' | 'narrow' | undefined | — | |
value | number | The byte size to format |
#RelativeTime
| Prop | Type | Default | Description |
|---|---|---|---|
localeMatcher | Intl.RelativeTimeFormatLocaleMatcher | The locale matching algorithm to use. For information about this option, see Intl page. | |
numeric | Intl.RelativeTimeFormatNumeric | The format of output message. | |
style | Intl.RelativeTimeFormatStyle | The length of the internationalized message. | |
value | Date | The date to format |
#Time
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | Date | The time to format |