Back to CSS Input Fields Currency Input Pure CSS
Share
HTML
<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>
CSS
.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;
}