---
title: "InputGroup"
description: "Joins an input with prefix and suffix addons inside one frame."
category: "Form & Input"
slug: input-group
url: /components/input-group
since: "0.2.0"
status: "stable"
---

# InputGroup

Joins an input with prefix and suffix addons inside one frame.

## Import

```svelte
import { InputGroup } from '@elluzion/iv-ui';
```

## Preview

A protocol prefix and a unit suffix around one input.

```svelte
<script lang="ts">
	import { Input, InputGroup } from '@elluzion/iv-ui';

	let host = $state('orbital');
</script>

<div class="field-row">
	<InputGroup>
		{#snippet prefix()}<span>https://</span>{/snippet}
		<Input bind:value={host} aria-label="Host" />
		{#snippet suffix()}<span>.dev</span>{/snippet}
	</InputGroup>
</div>

<style>
	.field-row {
		width: 100%;
		max-width: 340px;
	}
</style>
```

## Usage

- `prefix` and `suffix` take snippets; keep the content short, such as a protocol, unit, or icon.
- `size` applies to the frame; keep the inner control on the same size.
- Use `disabled` on the group for a consistent dimmed frame, and on the control to block input.

## Examples

### Sizes

`sm`, `md`, and `lg` keep the addons aligned with the control.

```svelte
<script lang="ts">
	import { Input, InputGroup } from '@elluzion/iv-ui';
</script>

<div class="stack">
	<InputGroup size="sm">
		{#snippet prefix()}<span>sm</span>{/snippet}
		<Input size="sm" placeholder="Small" aria-label="Small size" />
	</InputGroup>
	<InputGroup>
		{#snippet prefix()}<span>md</span>{/snippet}
		<Input placeholder="Medium" aria-label="Medium size" />
	</InputGroup>
	<InputGroup size="lg">
		{#snippet prefix()}<span>lg</span>{/snippet}
		<Input size="lg" placeholder="Large" aria-label="Large size" />
	</InputGroup>
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-md);
		width: 100%;
		max-width: 340px;
	}
</style>
```

### With a button

The suffix can hold an action instead of text.

```svelte
<script lang="ts">
	import { Button, Input, InputGroup } from '@elluzion/iv-ui';

	let query = $state('deploy logs');
	let submitted = $state('');

	function submit() {
		submitted = query;
	}
</script>

<div class="stack">
	<InputGroup>
		<Input bind:value={query} aria-label="Search" placeholder="Search the archive" />
		{#snippet suffix()}<Button size="sm" variant="ghost" onclick={submit}>Search</Button>{/snippet}
	</InputGroup>
	<p class="readout">last search: {submitted || '—'}</p>
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-sm);
		width: 100%;
		max-width: 380px;
	}

	.readout {
		margin: 0;
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-sm);
		color: var(--iv_foreground-dim);
	}
</style>
```

### Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Control size shared by the group and its addons. |
| `disabled` | `boolean` | `false` | Disables interaction and applies the disabled treatment. |
| `className` | `string` | `''` | Extra classes merged onto the root element. |

### Snippets

| Snippet | Type | Description |
| --- | --- | --- |
| `prefix` | `Snippet` | Content rendered before the input, such as a protocol or icon. |
| `suffix` | `Snippet` | Content rendered after the input, such as a unit or button. |
| `children` | `Snippet` | The input control. |

### Tokens used

`--iv_border` · `--iv_border-focus` · `--iv_border-hover` · `--iv_control-pad-x` · `--iv_control-pad-x-lg` · `--iv_control-pad-x-sm` · `--iv_cursor` · `--iv_disabled-opacity` · `--iv_ease-in-out` · `--iv_font-ui` · `--iv_foreground-dim` · `--iv_radius-sm` · `--iv_ring` · `--iv_ring-width` · `--iv_surface-elevated` · `--iv_surface-raised` · `--iv_text-body` · `--iv_text-body-sm` · `--iv_text-label` · `--iv_transition-base`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-addon` · `.iv-control` · `.iv-disabled` · `.iv-input-group` · `.iv-input-wrapper` · `.iv-lg` · `.iv-native-select` · `.iv-prefix` · `.iv-sm` · `.iv-suffix` · `.iv-textarea-wrapper` · `.iv-trigger`

## Accessibility

- The group is a visual container only; label the inner control itself.
- Focus styling is applied to the whole frame through `:focus-within`.

## Related

- [Input](/components/input.md)
- [NativeSelect](/components/native-select.md)
- [Field](/components/field.md)
- [Select](/components/select.md)