Input
A single-line text field with an optional label, helper, and error state.
import { Input } from '@elluzion/iv-ui'; 01 Preview
States
Default, filled, error, disabled, and read-only.
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>02 Usage
- Bind
valuefor two-way state:bind:value. - The label is rendered inside the field component — no external
<label>needed. - Pass
errorto switch to the error treatment;helperis replaced by the error message.
03 Examples
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.
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.
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>04 API
import { Input } from '@elluzion/iv-ui';Props
19 props · 5 events · 2 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'text' | 'password' | 'email' | 'number' | 'search' | 'url' | 'tel' | 'text' | Native input type. |
| value bindable | string | '' | Current value. Bind with bind:value. |
| placeholder | string | '' | Placeholder shown while the field is empty. |
| disabled | boolean | false | Disables interaction and applies the disabled treatment. |
| readonly | boolean | false | Prevents editing while keeping the value focusable and readable. |
| required | boolean | false | Marks 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 | boolean | false | Shows 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
| Event | Handler type | Description |
|---|---|---|
| oninput | (e: Event) => void | Called on every keystroke with the native event. |
| onchange | (e: Event) => void | Called when the value is committed. |
| onfocus | (e: FocusEvent) => void | Called when the control receives focus. |
| onblur | (e: FocusEvent) => void | Called when the control loses focus. |
| onkeydown | (e: KeyboardEvent) => void | Called on keydown with the native keyboard event. |
The legacy on:name form is accepted for every event.
Snippets
| Snippet | Type | Description |
|---|---|---|
| leadingIcon | Snippet | Snippet rendered inside the field, before the text. |
| trailingIcon | Snippet | Snippet rendered inside the field, after the text. |
05 Accessibility
| Keys | Action |
|---|---|
| Tab | Moves focus into the field. |
| Escape | Clears 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 getsaria-invalid.
06 Tokens & CSS hooks
Tokens used
--iv_border --iv_border-error --iv_border-focus --iv_border-hover --iv_control-md --iv_control-pad-x --iv_control-pad-x-lg --iv_control-pad-x-sm --iv_control-pad-y --iv_control-pad-y-lg --iv_control-pad-y-sm --iv_cursor --iv_disabled-opacity --iv_ease-in-out --iv_error --iv_error-surface --iv_font-mono --iv_font-ui --iv_foreground --iv_foreground-dim --iv_outline-offset --iv_outline-width --iv_radius-sm --iv_ring --iv_ring-width --iv_spacing-2xs --iv_spacing-md --iv_spacing-sm --iv_spacing-xs --iv_surface-overlay --iv_surface-raised --iv_text-base --iv_text-body-sm --iv_text-label --iv_text-lg --iv_text-sm --iv_transition-base
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