Skip to content
iv-ui v0.3.0

InputGroup

since 0.2.0

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

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

Addons

A protocol prefix and a unit suffix around one input.

https://
.dev
Source· svelte Show Hide
<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>
  • 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.

Sizes

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

sm
md
lg
Source· svelte Show Hide
<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.

last search: —

Source· svelte Show Hide
<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>
import { InputGroup } from '@elluzion/iv-ui';

Props

3 props · 0 events · 3 snippets
PropTypeDefaultDescription
size 'sm' | 'md' | 'lg''md'Control size shared by the group and its addons.
disabled booleanfalseDisables interaction and applies the disabled treatment.
className string''Extra classes merged onto the root element.

Snippets

SnippetTypeDescription
prefixSnippetContent rendered before the input, such as a protocol or icon.
suffixSnippetContent rendered after the input, such as a unit or button.
childrenSnippetThe input control.
  • The group is a visual container only; label the inner control itself.
  • Focus styling is applied to the whole frame through :focus-within.
Class 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
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records