Skip to content

Inputs with Icons and Add-ons

Tailwind CSS input group examples with leading icons, text prefixes and suffixes, a currency select, password toggle, clear button and helper text.

Also known as: input group, input with icon, input prefix suffix, form input add-ons, text field with icon

Tailwind CSS Inputs Responsive #form #icons #input #input-group #responsive

Inputs with Icons and Add-ons live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A set of form inputs with leading icons, text prefixes, suffix add-ons, an inline currency select and helper text, built with Tailwind CSS utilities and a few lines of vanilla JavaScript. Shown as a "Store settings" card, it covers the input patterns most admin panels, checkout forms and settings pages need, including success and error states.

How it works

The root is section.tig-inputs, which holds a white card with a two-column grid from the sm breakpoint. There are two input patterns:

  • Icon inputs (email, search, password, discount code): a relative wrapper with an absolutely positioned SVG and a full-width input that reserves room for it with pl-10 (or pr-10 for a trailing icon).
  • Add-on groups (website, store address, price, social handle): a flex wrapper that draws the border and uses focus-within:ring-4 to show focus, with a borderless input in the middle and span add-ons such as https://, .shop.example, $ and @ on either side. The price field ends with a native select for the currency.

Each input is tied to its helper text with aria-describedby. The social handle shows a success state (border-emerald-500 and a check icon), and the discount code shows an error state with aria-invalid="true" and red helper text.

The script initializes every .tig-inputs on DOMContentLoaded. Inside each data-tig-clearable wrapper the clear button (data-tig-clear) is hidden while the field is empty; clicking it, or pressing Escape in the field, empties the input and returns focus to it. Inside each data-tig-password wrapper, the eye button (data-tig-toggle) switches the input between password and text, flips aria-pressed and swaps the data-tig-eye and data-tig-eye-off icons. style.css only hides the browser's built-in search clear icon and Edge's password reveal button so they do not double up.

Customization

  • focus:border-orange-500, focus:ring-orange-500/15 and focus-within:ring-orange-500/15: swap orange for your brand color to change every focus state.
  • https://, .shop.example, $ and @ in the add-on span elements: replace with your own prefixes and suffixes such as kg, % or +1.
  • rounded-lg on inputs and groups: use rounded-full for pill inputs (also round the add-ons with rounded-l-full and rounded-r-full).
  • The option elements in #tig-currency: list the currencies you support.
  • sm:grid-cols-2 on the grid: use sm:grid-cols-1 for a single column of full-width fields.
  • To show an error on any field, add aria-invalid="true" and border-red-500 to the input and point aria-describedby at a red message, as #tig-code does.

Use cases

  • Admin panels: settings cards with email, search and password fields that carry leading icons
  • Checkout forms: price fields with a currency select and a discount code with error state
  • Store settings: website and address inputs with prefixes such as https:// and suffixes
  • Login forms: a password field with a show and hide toggle and a clear button on search

Accessibility

Every input has a visible label; the currency select has a visually hidden one. Icons and text prefixes are aria-hidden, while the .shop.example suffix is part of the field description so screen readers announce the full address. The clear button has the hidden label "Clear search", and the password button is a toggle button with aria-pressed and aria-controls. Focus is always visible through rings on the inputs and outlines on the buttons, and helper, success and error texts keep strong contrast against white.

Inputs with Icons and Add-ons at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Inputs
License
Free for personal and commercial use

Questions about this template

Can I use the Inputs with Icons and Add-ons code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

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

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Inputs with Icons and Add-ons – free Tailwind CSS input template
Inputs with Icons and Add-ons · free Tailwind CSS input template

More Inputs

Password Strength Meter – free Bootstrap 5 input template

Password Strength Meter

Bootstrap 5 password input with show/hide toggle, four-step strength meter, live requirements checklist and confirmation match check.

Tag Input with Chips – free Bootstrap 6 input template

Tag Input with Chips

Dark Bootstrap 6 tag input that turns typed values into removable Chips, with suggestions, a tag limit, keyboard shortcuts and a live post preview.

Form Validation Styles – free Bootstrap 6 input template

Form Validation Styles

Bootstrap 6 signup form showing valid and invalid field states with specific feedback messages, a live status checklist and a simulated submit.

OTP Code Input – free Bootstrap 6 input template

OTP Code Input

Dark Bootstrap 6 OtpInput verification card with 6 digit slots, paste support, auto-advance, auto-verify on complete, error state and a resend countdown.

Password Input with Strength Meter – free Bootstrap 6 input template

Password Input with Strength Meter

Bootstrap 6 password field with show/hide toggle, the Strength meter, a live requirement checklist, confirm match, Caps Lock hint and a password generator.

Input Groups with Icons and Buttons – free Bootstrap 6 input template

Input Groups with Icons and Buttons

Bootstrap 6 input group examples in a settings card: icon and text prefixes, suffixes, a currency menu, stepper, copy button and validated coupon field.