Skip to content
iv-ui v0.3.0

Input

since 0.1.0

A single-line text field with an optional label, helper, and error state.

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

States

Default, filled, error, disabled, and read-only.

Lowercase, dashes only.

This repository is already linked.

Source· svelte Show Hide
<script lang="ts">
	import { Input } from '@elluzion/iv-ui';

	let filled = $state('atlas-core');
</script>

<div class="fields">
	<Input label="Project name" placeholder="atlas-core" />
	<Input label="Slug" bind:value={filled} helper="Lowercase, dashes only." />
	<Input label="Repository" value="atlas/core" error="This repository is already linked." />
	<Input label="Owner" value="elluzion" disabled />
	<Input label="Region" value="eu-west-1" readonly />
</div>

<style>
	.fields {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-lg);
		width: 100%;
		max-width: 320px;
	}
</style>
  • Bind value for two-way state: bind:value.
  • The label is rendered inside the field component — no external <label> needed.
  • Pass error to switch to the error treatment; helper is replaced by the error message.

Sizes

The label and helper scale with the control.

Source· svelte Show Hide
<script lang="ts">
	import { Input } from '@elluzion/iv-ui';
</script>

<div class="fields">
	<Input size="sm" label="Small" placeholder="sm" />
	<Input size="md" label="Medium" placeholder="md" />
	<Input size="lg" label="Large" placeholder="lg" />
</div>

<style>
	.fields {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-lg);
		width: 100%;
		max-width: 320px;
	}
</style>

Validation

error pairs with aria-invalid and aria-describedby.

Used for deploy notifications.

Source· svelte Show Hide
<script lang="ts">
	import { Input } from '@elluzion/iv-ui';

	let email = $state('');

	const error = $derived(
		email.length === 0 ? '' : email.includes('@') ? '' : 'Enter a valid email address.'
	);
</script>

<div class="fields">
	<Input
		type="email"
		label="Email"
		placeholder="you@example.com"
		bind:value={email}
		{error}
		helper="Used for deploy notifications."
		required
	/>
</div>

<style>
	.fields {
		width: 100%;
		max-width: 320px;
	}
</style>

Leading and trailing icons

Snippets sit inside the field frame; clearable adds a reset button.

Clearable shows a reset button while filled.

Source· svelte Show Hide
<script lang="ts">
	import { IconAt, IconSearch } from '@tabler/icons-svelte';
	import { Input } from '@elluzion/iv-ui';

	let query = $state('deployments');
	let email = $state('ada@atlas.dev');
</script>

<div class="fields">
	<Input label="Search" placeholder="Search projects…" bind:value={query}>
		{#snippet leadingIcon()}
			<IconSearch size={16} />
		{/snippet}
	</Input>
	<Input
		type="email"
		label="Email"
		bind:value={email}
		clearable
		helper="Clearable shows a reset button while filled."
	>
		{#snippet leadingIcon()}
			<IconAt size={16} />
		{/snippet}
	</Input>
</div>

<style>
	.fields {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-lg);
		width: 100%;
		max-width: 320px;
	}
</style>
import { Input } from '@elluzion/iv-ui';

Props

19 props · 5 events · 2 snippets
PropTypeDefaultDescription
type 'text' | 'password' | 'email' | 'number' | 'search' | 'url' | 'tel''text'Native input type.
value bindablestring''Current value. Bind with bind:value.
placeholder string''Placeholder shown while the field is empty.
disabled booleanfalseDisables interaction and applies the disabled treatment.
readonly booleanfalsePrevents editing while keeping the value focusable and readable.
required booleanfalseMarks the field as required.
name string''Form field name submitted with the surrounding form.
id string''Element id. A generated id is used when omitted.
autocomplete HTMLInputAttributes['autocomplete']—Native autocomplete hint.
minlength number—Minimum number of characters.
maxlength number—Maximum number of characters.
min number | string—Minimum value for numeric and date types.
max number | string—Maximum value for numeric and date types.
pattern string—Regular expression the value must match.
label string''Visible label for the control.
error string''Error message. Switches the control to the error treatment.
helper string''Helper text shown below the control.
clearable booleanfalseShows a reset button while the field has a value.
size 'sm' | 'md' | 'lg''md'Control size.

class, id, style, aria-*, and data-* are forwarded through rest props.

Events

EventHandler typeDescription
oninput(e: Event) => voidCalled on every keystroke with the native event.
onchange(e: Event) => voidCalled when the value is committed.
onfocus(e: FocusEvent) => voidCalled when the control receives focus.
onblur(e: FocusEvent) => voidCalled when the control loses focus.
onkeydown(e: KeyboardEvent) => voidCalled on keydown with the native keyboard event.

The legacy on:name form is accepted for every event.

Snippets

SnippetTypeDescription
leadingIconSnippetSnippet rendered inside the field, before the text.
trailingIconSnippetSnippet rendered inside the field, after the text.
KeysAction
TabMoves focus into the field.
EscapeClears the value when clearable is set.
  • The label is associated with the input through a generated id.
  • Error text is announced through aria-describedby; the input also gets aria-invalid.
Class hooks
.iv-clear-btn.iv-disabled.iv-error-message.iv-has-error.iv-helper-message.iv-icon.iv-input-lg.iv-input-sm.iv-input-wrapper.iv-label.iv-leading.iv-message.iv-required-mark.iv-trailing
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records