Money
StableAn amount that code worked out, in mono with tabular figures, in rupees by default.
Also known as currency, amount, price format
Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.
Rupees
Refund of ₹2,34,000 and a fee of ₹2,340.50.
<p className="text-fg">Refund of <Money value={234000} /> and a fee of <Money value={2340.5} />.</p>Formatted with the en-IN locale, so groups follow the lakh pattern.
When to use it
Marks a figure as something code counted. Mono and a dotted underline say it is exact, and a hidden note tells screen readers the same.
Made of: Arrow (optional) · Sign · Amount · Hidden note (optional)
Do and avoid
Refund due: ₹2,340. Calculated by code
The AI thinks you may get about ₹2,300. Calculated by code back.
Do
- Use it for every figure that code calculated.
- Pass the currency and locale when the money is not rupees.
- Use Mono for dates and ids that were computed.
Avoid
- Do not use it for numbers the AI guessed.
- Do not use direction colours without the arrow and sign. Direction adds both for you.
- Do not print a raw number next to a currency sign yourself.
On a phone
- It is plain text in a monospace font with no fixed width, so it takes the size of the text around it.
- Use the compact prop for tight spaces, which gives lakh and crore forms for INR.
- The note that code calculated the amount is read by screen readers only, so a phone shows just the dotted underline.
Properties
| Prop | Type | Default | Description |
|---|---|---|---|
| valuerequired | number | none | The amount. A value that is not a finite number shows an em dash. |
| currency | string | "INR" | ISO 4217 currency code. |
| locale | string | "en-IN" | Locale for grouping and symbols. |
| compact | boolean | false | Short form. Lakh (L) and crore (Cr) for INR, K and M through Intl for others. |
| showSign | boolean | false | Prefix + for a positive number. A negative number always shows the true minus sign. |
| direction | boolean | false | For a non-zero number, adds an arrow, a sign and the up or down text colour. |
| calculated | boolean | string | none | Adds a dotted underline and a hidden note. A string replaces the default phrase Calculated by code. |
| className | string | none | Classes for the span. |
"Show code under the preview gives the code for the example on the stage."
In Figma
In Figma, one Money switches all of this from its properties panel, across 8 variants. Each property sets the React prop beside it, so design and code use the same names.
| Figma property | React | Values |
|---|---|---|
| Compact | compact | On or off |
| Show sign | showSign | On or off |
| Direction | direction | On or off |
States
States this part has beyond its default look. Build each one your screen can reach. States set by a property are in the Code tab.
- not a number
- A value that is not a finite number shows an em dash, never NaN.
- negative
- A negative amount shows the true minus sign before the currency.
Tokens
Change one of these and every part that uses it follows.
--font-mono--up-fg--down-fg--fg-subtle
Built in
- The amount is plain text, so it is read as written.
- With direction, the arrow is hidden and a hidden word Up or Down is read before the sign and amount.
- A negative amount uses the true minus sign.
- The calculated note is linked with aria-describedby and is not shown as a tooltip.
- A value that is not a number shows an em dash, never NaN.
What you need to do
- Use direction only when the sign and arrow add meaning, and do not rely on its colour alone.
- Do not use Money for amounts the AI estimated. The mono look promises that code worked it out.
Built toward WCAG 2.2 AA and checked automatically; no independent audit yet. Read the accessibility guide