4
0
forked from crowetic/commerce
commerce/components/price.tsx
2023-07-24 19:40:29 -07:00

20 lines
479 B
TypeScript

const Price = ({
amount,
currencyCode = 'USD',
...props
}: {
amount: string;
currencyCode: string;
} & React.ComponentProps<'p'>) => (
<p suppressHydrationWarning={true} {...props}>
{`${new Intl.NumberFormat(undefined, {
style: 'currency',
currency: currencyCode,
currencyDisplay: 'narrowSymbol'
}).format(parseFloat(amount))}`}
<span className="hidden @[275px]/label:inline">{` ${currencyCode}`}</span>
</p>
);
export default Price;