bank/components/Currency.tsx

21 lines
416 B
TypeScript
Raw Normal View History

2024-08-24 11:31:45 -05:00
import { JSX } from 'preact/jsx-runtime'
export const currencyFormat = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
maximumFractionDigits: 2,
minimumFractionDigits: 2,
})
export function Currency(
{ amount, ...props }:
& { amount: number }
& JSX.HTMLAttributes<HTMLSpanElement>,
) {
return (
<span class='font-mono' {...props}>
{currencyFormat.format(amount)}
</span>
)
}