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. Add the block. It brings what it builds on with it.
terminalnpx shadcn@latest add https://ui.twelfth.ai/r/retail-format.json2. Optional: register the namespace in
components.jsonto writenpx shadcn add @twelfth/retail-formatfrom then on.components.json{ "registries": { "@twelfth": "https://ui.twelfth.ai/r/{name}.json" } }
API reference
functions
| Prop | Type | Default | Description |
|---|---|---|---|
| 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 / formatMarketPosition | string | — | 12% above / 12% above market / In line with market. |
| formatWeeks(weeks) | string | — | 6.3 wks, 1 wk. |
