Input handbook
v1.2.0 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Provide single-line entry for text, search, password, number, date, time, and color, with composable labels, icons, and validation feedback.
When to use it
Use Input for single-line entry, SearchInput for dedicated search, and Textarea for multiple lines. Compose with Field when labels, help, or errors share one surface.
bind:valuesynchronizes edits. Explicitvaluewins overdefaultValue; number input still produces a string that applications convert for calculations.nameparticipates in form submission. Controlled forms restore their bound initial value on reset.bind:elementexposes the outer Frame element, not the native input.fileandrangeare not upload or slider modes. Useas="leading"/as="trailing"for accessories; a built-in clear control can occupy trailing.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Form composition and spacing
Field rhythm: default 12px vertical / 16px horizontal padding and 8px gap.
Standalone Input has its own 12px / 16px padding and 8px internal gap.
Input owns icon placement: leading/trailing icons sit 16px from the nearest visible inner edge by default.
The built-in error icon follows the same trailing icon rule without an overlay offset.
Inside Field, first distinguish whether Input uses
as="segment".Without
as="segment", Field owns padding and gap; Input drops its padding but keeps its internal gap.With
as="segment", Input keeps padding and gap and maintains 16px icon clearance from its border or divider.Adjacent row segments have vertical dividers; adjacent column segments have horizontal dividers.
Only one divider appears between neighboring segments.
label,description, anderrorare content, not owners of padding, gaps, or dividers.The
label + host + errorpattern supplies text; it does not determine padding or gap.In a connected
Field roworField column, mark child inputs explicitlyas="segment".
Component role
Input is the interactive host of a field, not necessarily the entire field surface:
Standalone Input retains its complete default input-box appearance.
Inside Field, Field takes over surface padding and gap unless Input is marked
as="segment".Combine Input with Icon, Text, Checkbox, Switch, Badge, or
Frame as="row"for richer fields.Text mode uses a visible native
<input>. Date and color modes use a visible display layer with a hidden native host synchronized to the value.
Inherited Frame capabilities
The outer Frame retains shared capabilities:
responsive / stateStyle / customStates / variants / stylesHover / Click / Focus / whileAppear / timeline / orchestrateloading / skeleton / renderHintsas / use / layoutId / itemId / scope / access
Input uses Frame as its surface. Text mode directly renders a visible native input and its event chain. Date/color modes assign value synchronization, form ownership, and picker opening to a hidden native host, while a custom layer displays text or color.
Error feedback and shake
invalid shows a stable error border, aria-invalid, and warning icon. A one-shot shake is built in; no extra Prop or private CSS class is needed.
Use the ordinary invalid-state declaration:
Standalone Input shakes on invalid/aria-invalid. Inside Field, Input does not shake separately; Field aggregates error state and moves as one surface.
Error feedback does not focus an input or simulate focus-within. Focus comes from user action, autofocus, or application focus().
Input-specific Props
The following table corresponds to named Props item by item; see Frame for undeclared general capabilities.
Layout model
Main layout model: slot host layout. See LayoutProtocol §12.3 (specs/maintainers/LayoutProtocol.md).
The root owns a fixed single-line Leading / Control / Trailing layout with at least 4 CSS px between slots. Explicit gap=0 and root-font or gap-scale reductions retain the floor; larger original preferred gaps are preserved. Field owns external regions and continuous surfaces without rewriting Input internals. Internal date segments, color text and drawing structures retain their spacing.
Input root has three regions: Leading, Control, and Trailing.
The root is
Frame row;enableAutoLayoutis fixed internally. ExternalenableAutoLayout={false}does not disable Input’s slot layout.Direct
as="leading"/as="trailing"children can be complex; each side hugs its content.The native input or visible date/color layer fills Content and retains
min-width: 0.Custom trailing replaces default date/clear controls; the error icon still follows Input’s trailing rule.
Field takes over only outer surface, padding, and dividers; Input still positions its own icons and control.
Floating search mode
Place <Input as="search"> in a floating host with a header portal, such as Listbox or Popover. Input then:
Reads
headerElthroughLISTBOX_HEADER_PORTAL_KEYand moves into the fixed header after mount, outside the option scroller.Applies compact floating-panel padding, gap, and radius.
Suppresses the expanded focus ring during
:focus-withinwith--snowui-field-focus-ring-width: 0rem.Defaults
maxlengthto 100 when absent.
Within Listbox, it also connects filtering through ListboxOwnerContext.setFilterText when isListboxSearch is derived from listboxOwner. Inside Popover, it only takes the fixed-header presentation; no filtering side effect is added.
Shared selectors cover .snowui-quick-action-panel-header > .snowui-input, .snowui-listbox-header > .snowui-input, and .snowui-listbox > .snowui-input without duplicating each overlay’s rules.
Behavior
oninputwrites search text toListboxOwnerContext.filterText; Select derivesfilteredOptionsfor case-insensitive matching.Custom items added through
allowCustomValueremain visible regardless of filter text.When Listbox closes, synchronize Input and filter text back to an empty string.
On a custom option hover, a circular × delete button replaces the check icon, reusing Input’s clear SVG. Clicking it removes that option and clears selection if the option was selected.
Usage examples
Native capability boundary
Input is responsible for:
Passthrough of supported native
<input>attributes.value/defaultValueprecedence.bind:valuesynchronizationCombined
aria-invalidand componentinvalidstate.
Input is not responsible for:
Complete label/description layout; compose with Field. Input can generate its own error Text through the public
errorProp.Generating an autocomplete data source.
A centralized form-rule engine.
Application-specific error messages.
Usage examples
Displaying openable, copyable links
A “link input” that only opens and copies is not an editable field. Use CopyLink: it has a borderless input-like hover, underlines linked text on hover, opens in a new tab on click, and copies from the rest of its surface. See specs/reference/NaturalLanguageToSnowUI.md for mapping. Use Input when addresses must be edited or read-only selected values shown.
Accessibility and forms
For browser autofill, set
nameandautocomplete.For native suggestions, point
listat adatalist.When an error message is present, use
aria-describedbyto reference the Field description or error node.Perform schema or business validation at Field/form level, then pass its result as
invalidoraria-invalid.
Input style overlay
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
Input type and status
Required Props: no named required Props.
Two-way binding: bind:value, bind:element.
Inheritance statement: Omit<FrameProps, "tag">. The inheritance ability is subject to the public document of the base class; the fields in Omit have been excluded and cannot be used as they are according to the base class.
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
InputValue
Source: components/src/components/Input.svelte
ComponentPartsOf
Source: components/src/logic/component-parts.svelte.ts
ConfigurableComponentPartProps
Source: components/src/logic/component-parts.svelte.ts
ComponentPartControlledKey
Source: components/src/logic/component-parts.svelte.ts
External type source:
HTMLInputAttributes — svelte/elements