Input
src/lib/components/ui/input/
Purpose
Text input primitives for forms. The barrel exports three components:
Input(input.svelte) — the base shadcn-svelte™<input>wrapper. Handlesfilevs text types, animated focus border, andaria-invalidstyling.TextInput(text-input.svelte) —Inputwrapped in arelativediv with trailing chrome: a clearXbutton when editable, aCopyButton(with optional tooltip) when readonly, and an optionaltrailingsnippet for custom status icons.AsyncValidatedInput(async-validated-input.svelte) —TextInputwith debounced server-side validation. Showsidle | loading | valid | not-valid | api-errorstatus icons and exposes status viaonStatusChange.
input-chrome.ts exports shared class constants (inputControlHoverClasses,
inputTrailingIconColorClasses, inputTrailingIconButtonClasses) used to keep
trailing-icon styling consistent across inputs and the command palette.
Origin
shadcn-svelte™ (extended) — Input is the standard shadcn-svelte™ input
with Primebrick's border-primary-gradient / animated-border treatment.
TextInput and AsyncValidatedInput are Primebrick additions on top of it.
Usage
Plain Input
Code
File input
Code
TextInput — editable with clear button
Code
TextInput — readonly with copy tooltip
Code
AsyncValidatedInput — server-side uniqueness check
Code
Validation is debounced (DEBOUNCE_DELAY = 300ms) and only fires once the
value reaches MIN_CHARS = 3 characters. Pass externalInvalid to force the
not-valid UI from outside (e.g. when a form-level validator rejects the
field).
Props
Full prop table: see API reference — input.
Key props:
Input
value(bindable) — the input value.type— standard HTML input type, or"file".files(bindable) —FileListfortype="file".ref(bindable) — underlying<input>element.- Standard
HTMLInputAttributesare forwarded.
TextInput (extends Input)
onClear(() => void) — invoked after the clear button resetsvalueto"".clearLabel(string, default"Clear") —aria-label/titlefor the clear button.onCopy((status: "success" | "failure" | undefined) => void) — forwarded toCopyButton.copyTooltipLabel(string) — when set, wraps the copy button in aTooltip.copyAnimationDuration(number, default2000) —CopyButtonanimation.trailing(Snippet) — extra content rendered after the clear/copy button (e.g. an async status icon).readonly,disabled— switch the trailing chrome mode (readonly→ copy,editable→ clear,disabled→ none).
AsyncValidatedInput
validateFn((value: string) => Promise<ValidationResult>, required) — server validation callback.onStatusChange((status: ValidationStatus) => void) —idle | loading | valid | not-valid | api-error.externalInvalid(boolean, defaultfalse) — forcenot-validUI from outside.onChange((value: string) => void) — value change callback.- Standard input attributes (
name,id,placeholder,disabled,type,required,minlength,maxlength,pattern, aria/data attributes).