Componentpickers0.6 KB gzipZero dependencies

Masked Currency

Formatted currency price input with prefix badge and numeric mask.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add masked-currency

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { MaskedCurrency } from "@/components/ui/masked-currency"; <MaskedCurrency currency="$" defaultValue={4500} onValueChange={(cents) => console.log(cents)} />

Source code

masked-currency.tsx + 1 helper

Zero 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 />
PropTypeDescription
currencystringConfigures currency. (Default: "$")
valuenumberControlled value.
defaultValuenumberInitial value when uncontrolled. (Default: 4500)
onValueChange(cents: number, formatted: string) => voidCallback invoked on value change.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.