Catman · Foundations

Retail format

Money, units, percent, price index, position words and weeks, formatted the way a category manager reads them. en-AU and AUD by default.

@twelfth/retail-formatlib
formatMoney
$1,240.00
formatUnits
12,400
formatPercent
12%
formatIndex
112.4
formatMarketPosition
12% above market
formatWeeks
12 wks

Installation

  1. 1. Add the block. It brings what it builds on with it.

    terminal
    npx shadcn@latest add https://ui.twelfth.ai/r/retail-format.json
  2. 2. Optional: register the namespace in components.json to write npx shadcn add @twelfth/retail-format from then on.

    components.json
    {
      "registries": {
        "@twelfth": "https://ui.twelfth.ai/r/{name}.json"
      }
    }

API reference

functions

PropTypeDefaultDescription
formatMoney(value, { locale?, currency?, whole? })string—$1,234.50; whole drops the cents.
formatUnits(value, { locale? })string—12,840
formatPercent(value, { locale?, digits? })string—Already in percent units: 12.4 → 12%.
formatIndex(positionPct)string—Ours ÷ theirs × 100: 12.4 → 112.4.
formatPosition / formatMarketPositionstring—12% above / 12% above market / In line with market.
formatWeeks(weeks)string—6.3 wks, 1 wk.

No bad cookies on these shelves.

Essential cookies keep the store running. Analytics only if you choose.