28 CSS Input Field Designs

Currency Input

Right-aligned numeric input with an inline `$` prefix. `inputmode="decimal"` brings up the right mobile keyboard; `:focus-within` lights the prefix to match the field accent.

Pure CSS MIT licensed

Currency Input the 16th of 28 designs in the 28 CSS Input Field Designs collection. The design is implemented in pure CSS — no JavaScript required. Copy the HTML and CSS panels below into your project. Because the demo is pure CSS, it works in any framework or templating engine you happen to use. The design honours prefers-reduced-motion and uses real semantic markup, so it ships accessibility-ready out of the box.

Live preview

Open in playground

The code

<label class="if-curr">
  <span class="if-curr-label">Amount</span>
  <span class="if-curr-wrap">
    <span class="if-curr-prefix">$</span>
    <input type="text" name="amount" inputmode="decimal" pattern="[0-9.,]*" placeholder="0.00" />
    <span class="if-curr-suffix">USD</span>
  </span>
</label>
.if-curr {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 280px;
}

.if-curr-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #b8b6d4;
  text-transform: uppercase;
}

.if-curr-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  background: #1a1a22;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.if-curr-wrap:focus-within {
  border-color: #f5a84a;
  background: #1f1f2a;
}

.if-curr-prefix {
  color: #b8b6d4;
  font:
    600 14px/1 system-ui,
    sans-serif;
  transition: color 0.2s;
}

.if-curr-wrap:focus-within .if-curr-prefix {
  color: #f5a84a;
}

.if-curr input {
  flex: 1;
  min-width: 0;
  padding: 12px 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #f0eeff;
  font:
    600 14px/1 system-ui,
    sans-serif;
  text-align: right;
  -moz-appearance: textfield;
}

.if-curr input::-webkit-outer-spin-button,
.if-curr input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.if-curr input::placeholder {
  color: #b8b6d4;
}

.if-curr-suffix {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: #b8b6d4;
  letter-spacing: 0.06em;
}

Search CodeFronts

Loading…