Homelogologo
Sponsor

Format

A set of components used to format numbers, bytes, and relative time according to the current locale.

Usage

import { Format } from "@elemnts-ui/react"; <Format.Number value={1234.56} style="currency" currency="USD" />;

Number

The component formats a number based on the current locale and specified options. It uses the Intl.NumberFormat API internally.

Byte

The component formats a byte value into a human-readable string (e.g., KB, MB, GB).

Relative Time

The component formats a date into a relative time string (e.g., "2 days ago", "in 5 minutes"). It uses the Intl.RelativeTimeFormat API internally.

API Reference

FormatNumber

Formats a number using the Intl.NumberFormat API.

PropTypeDefault
valuenumber-

FormatByte

Formats a byte size into a human-readable string.

PropTypeDefault
valuenumber-
unit'bit' | 'byte''byte'
unitDisplay'short' | 'long' | 'narrow''short'
unitSystem'decimal' | 'binary''decimal'

FormatRelativeTime

Formats a date into a relative time string using the Intl.RelativeTimeFormat API.

PropTypeDefault
valueDate-