Use to display monetary amounts, typically on dashboards or other layouts to show an overview or summary. User understanding increase when paired with labels.
Cents is automatically ".00" unless other wise overwritten (i.e. unit prop).
import React from 'react' import Currency from 'playbook-ui' const CurrencyVariants = (props) => { return ( <> <Currency amount="2,000.50" emphasized={false} label="Emphasized False" marginBottom="md" size="sm" /> <Currency amount="342" label="Light" marginBottom="md" size="sm" symbol="€" variant="light" /> <Currency amount="45" label="Bold" size="sm" unit="/mo" variant="bold" /> </> ) } export default CurrencyVariants
import React from 'react' import Currency from 'playbook-ui' const CurrencySize = (props) => { return ( <> <Currency amount="2,000.50" label="Small" marginBottom="md" size="sm" /> <Currency amount="342" label="Medium" marginBottom="md" size="md" symbol="€" /> <Currency amount="45" label="Large" size="lg" unit="/mo" /> </> ) } export default CurrencySize
import React from 'react' import Currency from 'playbook-ui' const CurrencyAlignment = (props) => { return ( <> <Currency amount="2,000.50" label="Left" size="sm" /> <Currency align="center" amount="342" label="Center" size="sm" symbol="€" /> <Currency align="right" amount="45" label="Right" size="sm" unit="/mo" /> </> ) } export default CurrencyAlignment
import React from 'react' import Currency from 'playbook-ui' const CurrencyAbbreviated = (props) => { return ( <> <Currency abbreviate amount="2,500" label="Thousands (with Unit)" marginBottom="md" size="md" unit="/mo" /> <Currency abbreviate amount="45300000" label="Millions" marginBottom="md" size="md" /> <Currency abbreviate amount="6,700,000,000" label="Billions" marginBottom="md" size="md" /> <Currency abbreviate amount="9,900,000,000,000" label="Trillions" size="md" /> </> ) } export default CurrencyAbbreviated
import React from 'react' import Currency from 'playbook-ui' const CurrencyMatchingDecimals = (props) => { return ( <> <Currency amount="372.12" decimals="matching" label="Small" marginBottom="md" size="sm" unit="/day" /> <Currency amount="30,327.43" decimals="matching" label="Medium" marginBottom="md" size="md" symbol="€" /> <Currency amount="621,953.99" decimals="matching" label="Large" size="lg" /> </> ) } export default CurrencyMatchingDecimals
For alternative typography styles, you can pass a boolean prop called unstyled
to the Currency
kit and wrap it in any of our typography kits (Title
, Body
, Caption
, etc.). This will allow the Currency
kit to inherit any of our typography styles.
import React from 'react' import { Currency, Title } from 'playbook-ui' const CurrencyUnstyled = (props) => { return ( <> <Currency amount="2,000.50" label="Basic unstyled example" marginBottom="md" unstyled /> <Title size={1} > <Currency amount="2,000.50" label="Example with wrapping typography kit" unstyled /> </Title> </> ) } export default CurrencyUnstyled
The optional commaSeparator
can be used to auto-format the use of commas as a thousands separator.
NOTE: If the value passed into the amount
prop is already comma-dilineated, it will not add additional commas.