Skip to Content

Amount

A money amount with the locale's digit grouping, the currency's own decimals and an optional credit or debit colour.

₹12.5LRevenue this month
import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function AmountDemo() {
  return (
    <div className="flex flex-col gap-2 text-center">
      <Amount value={1250000} notation="compact" className="text-3xl font-semibold" />
      <span className="text-sm text-neutral-500">Revenue this month</span>
    </div>
  )
}

Installation

npm i @dapplelight/signet-ui

Usage

import { Amount, formatAmount } from "@dapplelight/signet-ui/domain/amount"

<Amount value={1250000} notation="compact" />

Examples

Compact

₹12.5LRevenue this month
import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function AmountDemo() {
  return (
    <div className="flex flex-col gap-2 text-center">
      <Amount value={1250000} notation="compact" className="text-3xl font-semibold" />
      <span className="text-sm text-neutral-500">Revenue this month</span>
    </div>
  )
}

Locales

₹1,25,00,000.00$12,500,000.00¥12,500,000
import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function AmountLocaleDemo() {
  return (
    <div className="flex flex-col gap-1 text-lg">
      <Amount value={12500000} />
      <Amount value={12500000} locale="en-US" currency="USD" />
      <Amount value={12500000} locale="ja-JP" currency="JPY" />
    </div>
  )
}

Tone

₹4,999.00-₹1,299.00₹2,500.00-₹18,250.00
import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function AmountToneDemo() {
  return (
    <div className="flex flex-col gap-1 text-lg">
      <Amount value={4999} tone="credit" />
      <Amount value={-1299} tone="debit" />
      <Amount value={2500} tone="transfer" />
      <Amount value={-18250} tone="auto" />
    </div>
  )
}

Minor units

₹12,345.67₹12,34,568
import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function AmountMinorUnitsDemo() {
  return (
    <div className="flex flex-col gap-1 text-lg">
      <Amount value={1234567} minorUnits />
      <Amount value={123456789n} minorUnits notation="whole" />
    </div>
  )
}

Lakh and crore

₹1.3L₹1.3Cr$1.3M
import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function AmountCompactDemo() {
  return (
    <div className="flex flex-col gap-1 text-lg">
      <Amount value={125000} notation="compact" />
      <Amount value={12500000} notation="compact" />
      <Amount value={1250000} notation="compact" locale="en-US" currency="USD" />
    </div>
  )
}

Parts

₹48,250.75
import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function AmountPartsDemo() {
  return (
    <Amount
      value={48250.75}
      className="text-2xl font-semibold"
      classNames={{ currency: "text-neutral-400", fraction: "text-base text-neutral-500" }}
    />
  )
}

API Reference

Amount

PropTypeDefaultDescription
valuenumber | string | bigint—The amount. Use a bigint for exact minor units.
currencystring"INR"ISO 4217 code.
localestring"en-IN"Indian locales group by lakh and crore.
minorUnitsbooleanfalsevalue is in paise or cents: 12345 INR is ₹123.45.
notation"standard" | "whole" | "compact""standard"Standard shows the currency's decimals, whole none, compact shortens (₹12.5L, $1.3M).
decimalsnumber—Overrides the number of decimals. In compact notation it is the maximum (default 1).
tone"credit" | "debit" | "transfer" | "auto"—Colour from the theme's money slots. auto picks credit or debit from the sign.
signDisplayIntl.NumberFormatOptions["signDisplay"]"auto"Defaults to exceptZero when tone is auto, so the sign is never shown by colour alone.
classNamesPartial<Record<AmountPart, string>>—Classes per part: sign, currency, integer, fraction, compact.
renderReact.ReactElement—Replaces the <data> element, keeping props and parts.
titlestring—Compact amounts default to the full amount on hover.

formatAmount

PropTypeDefaultDescription
valueAmountValue—The amount to format.
optionsPick<AmountProps, "currency" | "locale" | "minorUnits" | "notation" | "decimals" | "signDisplay">{}Same options as the component. Returns { parts, major, sign }, for table cells and chart labels.