Pure TailwindMIT licensed

Tailwind Currency Input

Right-aligned money with an inline $ that lights up on focus. tabular-nums keeps digit widths locked as the user types — the detail that makes a column of amounts stop shimmering.

Live Demo
Plain CSSTailwind v4
Try it

Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time

Untitled UI React · Affiliate link

Get Untitled UI Pro

The code

<div class="tif-16 grid min-h-svh w-full place-items-center bg-tif16-bg px-6 py-14 font-tif16-sans" aria-label="Currency input demo">
  <label class="grid w-full max-w-70 gap-1.5">
    <span class="font-tif16-mono text-[10px] tracking-[0.12em] text-tif16-mut uppercase">Amount</span>
    <span class="group flex items-center gap-1.5 rounded-[10px] border border-white/12 bg-tif16-field px-3.5 transition-[border-color,background-color] duration-200 focus-within:border-tif16-acc focus-within:bg-tif16-field2">
      <span class="text-sm font-semibold text-tif16-mut transition-colors duration-200 group-focus-within:text-tif16-acc" aria-hidden="true">$</span>
      <input type="text" name="tif16-amount" inputmode="decimal" pattern="[0-9.,]*" placeholder="0.00"
        class="min-w-0 flex-1 border-0 bg-transparent py-3 text-right text-sm font-semibold tabular-nums text-tif16-ink outline-none placeholder:text-tif16-mut">
      <span class="font-tif16-mono text-[10px] tracking-[0.06em] text-tif16-mut">USD</span>
    </span>
  </label>
</div>
@import "tailwindcss";

@theme {
  --color-tif16-bg: #12121a;
  --color-tif16-bg: oklch(0.19 0.015 285);
  --color-tif16-field: #1a1a22;
  --color-tif16-field: oklch(0.23 0.015 285);
  --color-tif16-field2: #1f1f2a;
  --color-tif16-field2: oklch(0.26 0.018 285);
  --color-tif16-ink: #f0eeff;
  --color-tif16-ink: oklch(0.95 0.02 290);
  --color-tif16-mut: #b8b6d4;
  --color-tif16-mut: oklch(0.77 0.03 290);
  --color-tif16-acc: #f5a84a;
  --color-tif16-acc: oklch(0.79 0.13 70);
  --font-tif16-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-tif16-mono: 'JetBrains Mono', ui-monospace, monospace;
}

.tif-16 {
  width: 100%;
}

.tif-16 ::selection {
  background: var(--color-tif16-acc);
  color: #12121a;
}

Setup — do this once per project

Skip this if your project already runs Tailwind v4.

1Load Tailwind
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

Compiles in the browser — perfect for a CodePen or a quick test, not for production.

2Add the stylesheetRequiredthe @theme block is what makes the custom utilities exist
@import "tailwindcss";

@theme {
  --color-tif16-bg: #12121a;
  --color-tif16-bg: oklch(0.19 0.015 285);
  --color-tif16-field: #1a1a22;
  --color-tif16-field: oklch(0.23 0.015 285);
  --color-tif16-field2: #1f1f2a;
  --color-tif16-field2: oklch(0.26 0.018 285);
  --color-tif16-ink: #f0eeff;
  --color-tif16-ink: oklch(0.95 0.02 290);
  --color-tif16-mut: #b8b6d4;
  --color-tif16-mut: oklch(0.77 0.03 290);
  --color-tif16-acc: #f5a84a;
  --color-tif16-acc: oklch(0.79 0.13 70);
  --font-tif16-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-tif16-mono: 'JetBrains Mono', ui-monospace, monospace;
}

.tif-16 {
  width: 100%;
}

.tif-16 ::selection {
  background: var(--color-tif16-acc);
  color: #12121a;
}
3Fonts used by this demooptional — skip if you have your own type stack
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Plus+Jakarta+Sans:wght@400;500;600&display=swap">

What changed in the port

Which parts became utilities, which stayed CSS, and why.

  • tabular-nums moved from the customisation list into the markup. It is the difference between a money field and a text field, not an optional extra.
  • The -moz-appearance: textfield and spin-button resets are gone with type=&quot;number&quot; — they were never needed on a text input.
  • The prefix's focus tint is group-focus-within: rather than a descendant rule, so the shell's state is read once.
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS demo from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Tailwind Currency Input
Source: https://codefronts.com/components/tailwind-css-input-fields/tailwind-currency-input/

Right-aligned money with an inline $ that lights up on focus. tabular-nums keeps digit widths locked as the user types — the detail that makes a column of amounts stop shimmering.
## HTML
```html
<div class="tif-16 grid min-h-svh w-full place-items-center bg-tif16-bg px-6 py-14 font-tif16-sans" aria-label="Currency input demo">
  <label class="grid w-full max-w-70 gap-1.5">
    <span class="font-tif16-mono text-[10px] tracking-[0.12em] text-tif16-mut uppercase">Amount</span>
    <span class="group flex items-center gap-1.5 rounded-[10px] border border-white/12 bg-tif16-field px-3.5 transition-[border-color,background-color] duration-200 focus-within:border-tif16-acc focus-within:bg-tif16-field2">
      <span class="text-sm font-semibold text-tif16-mut transition-colors duration-200 group-focus-within:text-tif16-acc" aria-hidden="true">$</span>
      <input type="text" name="tif16-amount" inputmode="decimal" pattern="[0-9.,]*" placeholder="0.00"
        class="min-w-0 flex-1 border-0 bg-transparent py-3 text-right text-sm font-semibold tabular-nums text-tif16-ink outline-none placeholder:text-tif16-mut">
      <span class="font-tif16-mono text-[10px] tracking-[0.06em] text-tif16-mut">USD</span>
    </span>
  </label>
</div>
```
## CSS
```css
@import "tailwindcss";

@theme {
  --color-tif16-bg: #12121a;
  --color-tif16-bg: oklch(0.19 0.015 285);
  --color-tif16-field: #1a1a22;
  --color-tif16-field: oklch(0.23 0.015 285);
  --color-tif16-field2: #1f1f2a;
  --color-tif16-field2: oklch(0.26 0.018 285);
  --color-tif16-ink: #f0eeff;
  --color-tif16-ink: oklch(0.95 0.02 290);
  --color-tif16-mut: #b8b6d4;
  --color-tif16-mut: oklch(0.77 0.03 290);
  --color-tif16-acc: #f5a84a;
  --color-tif16-acc: oklch(0.79 0.13 70);
  --font-tif16-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-tif16-mono: 'JetBrains Mono', ui-monospace, monospace;
}

.tif-16 {
  width: 100%;
}

.tif-16 ::selection {
  background: var(--color-tif16-acc);
  color: #12121a;
}
```

How this works

The prefix reads the field's state. group on the shell, one variant on the $:

<span class="text-tif16-mut transition-colors
  group-focus-within:text-tif16-acc">$</span>

Why not type="number". It strips leading zeros, rejects locale separators, mangles a pasted 1,234.56 and shows a spinner nobody wants on a price. inputmode="decimal" gets the mobile keypad without any of that.

Make it yours

  • Symbol: the prefix span. For RTL currencies move it after the input and flip the text alignment.
  • Formatting: format on blur with Intl.NumberFormat, reparse on focus, keep the raw number in a hidden field.
  • Accent: --color-tif16-acc.
  • Density: py-3 on the input, px-3.5 on the shell.

Gotchas — read before shipping

  • Store money as integer minor units server-side. Float arithmetic will embarrass you on the third item in a cart.
  • inputmode=&quot;decimal&quot; needs iOS 12.5+ and Firefox 95+; older mobile browsers show the full keyboard, which is annoying but not broken.
  • tabular-nums only helps if the font has tabular figures — check before trusting it with a totals column.

Browser support

ChromeSafariFirefoxEdge
111+16.4+128+111+

inputmode gates the mobile keypad; the visual chrome works everywhere Tailwind v4 does.

Techniques used in this demo

Utilitiesfirst-class utility or variant

Theme tokensset in @theme, used by a utility

HTML & JSno Tailwind involved

Search CodeFronts

Loading…