Componentpickers0.6 KB gzipZero dependencies
Masked Currency
Formatted currency price input with prefix badge and numeric mask.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add masked-currencyOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { MaskedCurrency } from "@/components/ui/masked-currency"; <MaskedCurrency currency="$" defaultValue={4500} onValueChange={(cents) => console.log(cents)} />Source code
masked-currency.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxmasked-currency.tsx66 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface MaskedCurrencyProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> { currency?: string; value?: number; defaultValue?: number; onValueChange?: (cents: number, formatted: string) => void; className?: string;} export function MaskedCurrency({ currency = "$", value: controlledValue, defaultValue = 4500, // in cents (e.g. 4500 = $45.00)Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { MaskedCurrency } from "@/components/ui/masked-currency"; <MaskedCurrency />| Prop | Type | Description |
|---|---|---|
| currency | string | Configures currency. (Default: "$") |
| value | number | Controlled value. |
| defaultValue | number | Initial value when uncontrolled. (Default: 4500) |
| onValueChange | (cents: number, formatted: string) => void | Callback invoked on value change. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |