CSS Input with Prefix & Suffix
A text field with attached prefix and suffix labels, like a currency sign and code.
HTML
<label class="addon">
<span>$</span>
<input type="text" inputmode="decimal" placeholder="0.00" aria-label="Amount">
<span>USD</span>
</label>
CSS
.addon {
display: flex;
width: 100%;
max-width: 260px;
overflow: hidden;
border: 1px solid #d4d4d8;
border-radius: 10px;
background: #fff;
font: 15px system-ui, sans-serif;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.addon:focus-within {
border-color: #0ea5e9;
box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}
.addon span {
display: flex;
align-items: center;
padding: 0 12px;
background: #f4f4f5;
color: #71717a;
}
.addon span:first-child {
border-right: 1px solid #e4e4e7;
}
.addon span:last-child {
border-left: 1px solid #e4e4e7;
font-size: 13px;
font-weight: 600;
}
.addon input {
flex: 1;
min-width: 0;
padding: 11px 12px;
border: 0;
outline: 0;
background: transparent;
color: #18181b;
font: inherit;
}
About this CSS Input with Prefix & Suffix
This CSS Input with Prefix & Suffix is 45 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses transitions, box shadows and Flexbox. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#d4d4d8#fff#0ea5e9#f4f4f5#71717a#e4e4e7#18181b
How to use this input with prefix & suffix
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.addonclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.