X Enterprises
nuxt-x-app

Fmt

Lightweight display formatters for dates, currency, phone numbers, addresses, maps, percentages, file sizes, and structured data.

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

<XAFmtDateTime />

Renders a <time> element with a formatted date. Supports short, long, full, and relative display modes. The title attribute always shows the full locale date for accessibility.

<XAFmtDateTime :value="user.createdAt" format="long" :show-time="true" />
<XAFmtDateTime :value="post.publishedAt" format="relative" />

Props

PropTypeDefaultDescription
valueString | Date | NumberrequiredDate input (ISO string, Date object, or timestamp)
format'short' | 'long' | 'full' | 'relative''short'Display format
showTimeBooleanfalseInclude time in non-relative formats
localeStringundefinedBCP 47 locale tag (e.g., 'en-US')

<XAFmtCurrency />

Formats a number as a currency string using Intl.NumberFormat. Optionally colorizes positive values green and negative values red.

<XAFmtCurrency :value="invoice.total" currency="USD" :colorize="false" />
<XAFmtCurrency :value="balanceDelta" currency="EUR" :show-sign="true" :colorize="true" />

Props

PropTypeDefaultDescription
valueNumberrequiredNumeric value to format
currencyString'USD'ISO 4217 currency code
localeString'en-US'BCP 47 locale tag
showSignBooleanfalseAlways show +/- sign
colorizeBooleanfalseGreen for positive, red for negative

<XAFmtPhone />

Formats US phone numbers in various styles. Renders as a tel: anchor when clickable is true.

<XAFmtPhone value="5551234567" />
<!-- Output: (555) 123-4567 -->

<XAFmtPhone value="+15551234567" format="dashes" :clickable="true" />
<!-- Output: 555-123-4567 (clickable tel: link) -->

Props

PropTypeDefaultDescription
valueString | NumberrequiredRaw phone number
format'parentheses' | 'dashes' | 'dots' | 'spaces' | 'international''parentheses'Output format
clickableBooleanfalseRender as a tel: link
fallbackString'—'Text shown when value is empty
textClassString''Additional CSS classes

<XAFmtAddress />

Renders a postal address as a block (multi-line) or inline (comma-separated) format. Accepts either a structured address object or individual field props. Optionally appends a map link.

<!-- Object mode -->
<XAFmtAddress :address="contact.address" :show-map-link="true" />

<!-- Field mode -->
<XAFmtAddress
  street="123 Main St"
  city="Springfield"
  state="IL"
  zip="62701"
  :inline="true"
  :show-map-link="true"
  map-provider="google"
/>

Props

PropTypeDefaultDescription
addressObjectnullAddress object (supports street, street2, city, state, zip, country and common aliases)
streetString''Street line 1
street2String''Street line 2 / unit
cityString''City
stateString''State / region
zipString''Postal code
countryString''Country
inlineBooleanfalseSingle-line comma-separated format
showCountryBooleanfalseInclude country in output
showMapLinkBooleantrueAppend a "View on Map" link
mapLinkTextString''Custom map link label
mapProvider'google' | 'apple''google'Map provider for the link URL

<XAFmtMap />

Embeds a Google Maps iframe using the no-API-key embed URL. Accepts an address string, lat/lng coordinates, or a search query. Renders client-side only (<ClientOnly>).

<XAFmtMap address="1600 Amphitheatre Parkway, Mountain View, CA" :height="300" />
<XAFmtMap :lat="37.4224764" :lng="-122.0842499" :zoom="17" />
<XAFmtMap query="coffee shops near Times Square" map-type="satellite" />

Props

PropTypeDefaultDescription
addressStringnullAddress string to search for
queryStringnullFree-text search query
latNumbernullLatitude coordinate
lngNumbernullLongitude coordinate
zoomNumber15Zoom level (1–21)
widthString | Number'100%'Container width
heightString | Number300Container height (px)
mapType'roadmap' | 'satellite''roadmap'Map display type
allowFullscreenBooleantrueEnable fullscreen button
loading'lazy' | 'eager''lazy'Iframe loading strategy
containerClassString''Additional container CSS classes

<XAFmtRelativeTime />

Displays a date as human-readable relative time (e.g., "3 days ago") using Nuxt's built-in <NuxtTime> with SSR-safe hydration. Shows the full absolute date in the title tooltip.

<XAFmtRelativeTime :value="comment.createdAt" />
<XAFmtRelativeTime :value="task.dueDate" locale="en-GB" fallback="No date set" />

Props

PropTypeDefaultDescription
valueDate | String | NumberrequiredDate to format
localeString'en-US'BCP 47 locale tag
fallbackString'—'Text shown for invalid/missing dates
textClassString''Additional CSS classes

<XAFmtPercent />

Formats a percentage value with configurable decimal places, optional sign, color coding (threshold-based or change-based), and a trend arrow icon.

<XAFmtPercent :value="85.5" />
<!-- Output: 85.5% -->

<XAFmtPercent :value="25" :colorize="true" />
<!-- Output: 25% (red — below 50 threshold) -->

<XAFmtPercent :value="-12.5" :colorize-change="true" :show-sign="true" :show-trend="true" :trend="-1" />
<!-- Output: -12.5% (red, with down arrow) -->

Props

PropTypeDefaultDescription
valueNumberrequiredPercentage value (0–100 scale by default)
decimalsNumber1Number of decimal places
showSignBooleanfalseShow + for positive values
colorizeBooleanfalseColor by threshold: <low = red, <medium = yellow, else green
colorizeChangeBooleanfalseColor as change: positive = green, negative = red
thresholdsObject{ low: 50, medium: 75 }Custom thresholds for colorize mode
showTrendBooleanfalseShow a trend arrow icon
trendNumber0Trend direction: 1 (up), -1 (down), 0 (none)
localeString'en-US'BCP 47 locale tag
textClassString''Additional CSS classes

<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

PropTypeDefaultDescription
valueNumberrequiredFile size in bytes
decimalsNumber2Decimal places
binaryBooleanfalseUse binary units (KiB, MiB, GiB)
localeString'en-US'BCP 47 locale for number formatting
fallbackString'0 B'Text shown for zero or null values
textClassString''Additional CSS classes

<XAFmtData />

Renders a plain JavaScript object or explicit field array as a <dl> list with type-aware value formatting. Supports badges, booleans, links, emails, currency, dates, and copyable values. Useful for ad-hoc data display without defining a full XADetailPanel.

<!-- Object mode (auto-generates labels from keys) -->
<XAFmtData :data="{ status: 'active', amount: 1500, email: 'test@example.com' }" />

<!-- Field array mode (explicit definitions) -->
<XAFmtData
  :data="[
    { key: 'status', label: 'Status', value: 'active', type: 'badge' },
    { key: 'amount', label: 'Amount', value: 1500, type: 'currency', currency: 'USD' },
    { key: 'email', label: 'Email', value: 'test@example.com', type: 'email' },
  ]"
  layout="horizontal"
  spacing="md"
/>

Props

PropTypeDefaultDescription
dataObject | ArrayrequiredPlain object (auto-converted) or array of field definitions
layout'horizontal' | 'vertical''horizontal'Side-by-side or stacked label/value layout
spacing'sm' | 'md' | 'lg''md'Spacing between items

Supported field type values: badge, boolean, link, email, currency, date, copy, and default (plain text).


AI Context

category: Fmt
package: "@xenterprises/nuxt-x-app"
components:
  - XAFmtDateTime
  - XAFmtCurrency
  - XAFmtPhone
  - XAFmtAddress
  - XAFmtMap
  - XAFmtRelativeTime
  - XAFmtPercent
  - XAFmtFileSize
  - XAFmtData
use-when: >
  Displaying raw data values in a formatted, human-readable way. Use instead
  of inline template expressions or manual Intl API calls. All components are
  stateless and purely presentational.
key-patterns:
  - All Fmt components are display-only — no user interaction or state
  - XAFmtData is a quick way to render any object as key-value pairs
  - XAFmtMap requires no Google Maps API key
  - XAFmtRelativeTime is SSR-safe via NuxtTime
  - XAFmtPercent covers both progress metrics (colorize) and delta values (colorizeChange)
Copyright © 2026