Skip to content
VinUIComponentsInput Group

Input Group

An input with text, icons or buttons attached. Same markup and props in every style: switch the style in the header to see it change.

Text before and after

Prefixes and suffixes such as a protocol or a currency. The whole group is drawn as an Input, so it matches every style.

https://
₹ per month
input-group-addons.html
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
  <div class="vin-field">
    <label class="vin-label" for="site">Website</label>
    <div class="vin-input vin-input-group">
      <span class="vin-input-group__addon">https://</span>
      <input id="site" class="vin-input-group__input" placeholder="example.com">
    </div>
  </div>
  <div class="vin-field">
    <label class="vin-label" for="price">Price (INR)</label>
    <div class="vin-input vin-input-group">
      <span class="vin-input-group__addon">₹</span>
      <input id="price" class="vin-input-group__input" inputmode="decimal" value="1,499">
      <span class="vin-input-group__addon">per month</span>
    </div>
  </div>
</div>

Icons

An icon at the start, a shortcut hint at the end.

⌘K

Enter a valid email address.

input-group-icons.html
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
  <div class="vin-input vin-input-group">
    <span class="vin-input-group__addon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></span>
    <input class="vin-input-group__input" type="search" placeholder="Search docs" aria-label="Search docs">
    <span class="vin-input-group__addon">⌘K</span>
  </div>
  <div class="vin-field">
    <label class="vin-label" for="ig-email">Email</label>
    <div class="vin-input vin-input-group">
      <span class="vin-input-group__addon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg></span>
      <input id="ig-email" class="vin-input-group__input" type="email" placeholder="you@example.com" aria-invalid="true" aria-describedby="ig-email-error">
    </div>
    <p class="vin-error" id="ig-email-error">Enter a valid email address.</p>
  </div>
</div>

With a button

Put a small Button inside an addon for copy, submit or show-password actions.

input-group-buttons.html
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
  <div class="vin-field">
    <label class="vin-label" for="api-key">API key</label>
    <div class="vin-input vin-input-group">
      <input id="api-key" class="vin-input-group__input" value="vin_live_8f2k…" readonly>
      <span class="vin-input-group__addon">
        <button type="button" class="vin-btn vin-btn--ghost vin-btn--icon" aria-label="Copy API key"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="12" height="12" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/></svg></button>
      </span>
    </div>
  </div>
  <div class="vin-input vin-input-group">
    <input class="vin-input-group__input" type="email" placeholder="you@example.com" aria-label="Email for newsletter">
    <span class="vin-input-group__addon"><button type="button" class="vin-btn">Subscribe</button></span>
  </div>
</div>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add input-group
React
import { InputGroup } from "@/components/vin/input-group";
Vue
import InputGroup from "@/components/vin/input-group.vue";
Svelte
import InputGroup from "$lib/components/vin/input-group.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/input-group.json, which every framework version is tested against.

PropValuesDefaultIn HTML
start / end
Text, an icon or a small Button before or after the input.
ReactNode—<span class="vin-input-group__addon">
sizesmmdlgmdvin-input--{value} on the group
label / hint / error
Same as Input's Field.
ReactNode—.vin-field, .vin-label, .vin-hint, .vin-error
…input props
Everything else goes to the <input>.
InputHTMLAttributes—on input.vin-input-group__input

Parts

React, Vue, SvelteHTML classes
<InputGroup>.vin-input-group.vin-input-group__input.vin-input-group__addon

Accessibility

  • The <input> has its own label; addons are visual and not part of its name.
  • If an addon carries meaning the label doesn't (a currency, a domain), say it in the label or hint too.
  • Buttons inside keep their own labels; icon-only buttons have an aria-label.
  • The focus ring wraps the whole group, so you always see where you are typing.