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.
<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>import { InputGroup } from "@/components/vin/input-group";
export function InputGroupAddons() {
return (
<div style={{ display: "grid", gap: 16, width: "100%", maxWidth: 320 }}>
<InputGroup label="Website" start="https://" placeholder="example.com" />
<InputGroup label="Price (INR)" start="₹" end="per month" inputMode="decimal" defaultValue="1,499" />
</div>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import InputGroup from "@/components/vin/input-group.vue";
</script>
<template>
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
<InputGroup label="Website" start="https://" placeholder="example.com" />
<InputGroup label="Price (INR)" start="₹" end="per month" inputmode="decimal" default-value="1,499" />
</div>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import InputGroup from "$lib/components/vin/input-group.svelte";
</script>
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
<InputGroup label="Website" start="https://" placeholder="example.com" />
<InputGroup label="Price (INR)" start="₹" end="per month" inputmode="decimal" value="1,499" />
</div>Icons
An icon at the start, a shortcut hint at the end.
Enter a valid email address.
<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>Enter a valid email address.
import { InputGroup } from "@/components/vin/input-group";
const Icon = ({ children }: { children: React.ReactNode }) => (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">{children}</svg>
);
export function InputGroupIcons() {
return (
<div style={{ display: "grid", gap: 16, width: "100%", maxWidth: 320 }}>
<InputGroup
type="search"
placeholder="Search docs"
aria-label="Search docs"
start={<Icon><circle cx="11" cy="11" r="7" /><path d="m20 20-3.5-3.5" /></Icon>}
end="⌘K"
/>
<InputGroup
label="Email"
type="email"
placeholder="you@example.com"
error="Enter a valid email address."
start={<Icon><rect x="3" y="5" width="18" height="14" rx="2" /><path d="m3 7 9 6 9-6" /></Icon>}
/>
</div>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import InputGroup from "@/components/vin/input-group.vue";
</script>
<template>
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
<InputGroup type="search" placeholder="Search docs" aria-label="Search docs" end="⌘K">
<template #start><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></template>
</InputGroup>
<InputGroup label="Email" type="email" placeholder="you@example.com" error="Enter a valid email address.">
<template #start><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></template>
</InputGroup>
</div>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import InputGroup from "$lib/components/vin/input-group.svelte";
</script>
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
<InputGroup type="search" placeholder="Search docs" aria-label="Search docs" end="⌘K">
{#snippet start()}<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>{/snippet}
</InputGroup>
<InputGroup label="Email" type="email" placeholder="you@example.com" error="Enter a valid email address.">
{#snippet start()}<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>{/snippet}
</InputGroup>
</div>With a button
Put a small Button inside an addon for copy, submit or show-password actions.
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:
npx @vinish/ui add input-groupimport { InputGroup } from "@/components/vin/input-group";import InputGroup from "@/components/vin/input-group.vue";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.
| Prop | Values | Default | In HTML |
|---|---|---|---|
start / endText, an icon or a small Button before or after the input. | ReactNode | — | <span class="vin-input-group__addon"> |
size | smmdlg | md | vin-input--{value} on the group |
label / hint / errorSame as Input's Field. | ReactNode | — | .vin-field, .vin-label, .vin-hint, .vin-error |
…input propsEverything else goes to the <input>. | InputHTMLAttributes | — | on input.vin-input-group__input |
Parts
| React, Vue, Svelte | HTML 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.
Customize
Saved in this browser. Style and accent are in the header.