Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Bar List
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Checkbox
- Checkbox Group
- Circular Progress
- Collapsible
- Combobox
- Command
- Context Menu
- Currency Input
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Meter
- Multi Combobox
- Native Select
- Navigation Menu
- Number Field
- Pagination
- Phone Input
- Popover
- Progress
- Progress List
- Prompt
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Stat
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Typography
Loading...
"use client";
import { useState } from "react";
import { CurrencyInput } from "@/components/ui/currency-input";
import { Label } from "@/components/ui/label";
export function CurrencyInputDemo() {
const [monthlyPrice, setMonthlyPrice] = useState<string | undefined>("29.00");
const [credit, setCredit] = useState<string | undefined>("100.00");
return (
<div className="grid w-full max-w-md gap-6">
<div className="space-y-1">
<p className="font-medium text-sm">Billing settings</p>
<p className="text-muted-foreground text-sm">
Configure workspace pricing and account credits.
</p>
</div>
<div className="space-y-2">
<Label htmlFor="monthly-price">Monthly price</Label>
<CurrencyInput
decimalSeparator="."
decimalsLimit={2}
groupSeparator=","
id="monthly-price"
name="monthlyPrice"
onValueChange={(value) => setMonthlyPrice(value)}
placeholder="Enter monthly price"
prefix="$"
value={monthlyPrice}
/>
<p className="text-muted-foreground text-sm">
Charged once per workspace each month.
</p>
</div>
</div>
);
}Installation
npx shadcn@latest add "https://ui.blode.co/r/styles/default/currency-input"
Usage
import { CurrencyInput } from "@/components/ui/currency-input";<CurrencyInput
placeholder="Enter an amount"
prefix="$"
groupSeparator=","
decimalSeparator="."
decimalsLimit={2}
/>Props
Currency Input extends react-currency-input-field with additional styling and clear/addon controls.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Class name applied to the input. |
clearClassName | string | - | Class name applied to the clear button. |
hasError | boolean | false | Shows error state with a destructive border. |
clearable | boolean | false | Enables a clear button when value is present. |
onClear | () => void | - | Callback fired when the clear button is clicked. |
leftAddon | React.ReactNode | - | Content displayed before the input field. |
rightAddon | React.ReactNode | - | Content displayed after the input field. |
leftControl | React.ReactNode | - | Absolute-positioned control on the left. |
rightControl | React.ReactNode | - | Absolute-positioned control on the right. |
prefix | string | - | Prefix rendered before the numeric value. |
suffix | string | - | Suffix rendered after the numeric value. |
decimalsLimit | number | - | Maximum number of decimal places allowed. |
decimalSeparator | string | . | Character used as the decimal separator. |
groupSeparator | string | , | Character used to group thousands. |
value | string | undefined | - | Controlled value. |
defaultValue | string | undefined | - | Initial uncontrolled value. |
onValueChange | (value: string | undefined, name?: string) => void | - | Callback fired when value changes. |