dssoca docs
GitHub repository

Input

Labelled text input with validation affordances.

A text input with an optional label and auto-wired id. Supports `hint` and `error` helper text (error implies aria-invalid and is announced), prefix/suffix snippets inside the field, a `clearable` button, readonly/disabled styling, and native attribute forwarding (`autocomplete`, `inputmode`, `maxlength`, …).

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { Input } from 'dssoca';
  let email = $state('');
</script>

<Input
  label="email"
  type="email"
  bind:value={email}
  placeholder="admin@hub.home"
  hint="we never share it"
  clearable
/>

Props

PropTypeDefaultDescription
labelstringVisible label (associated via generated id).
valuestring''Bindable value.
typestring'text'Native input type.
placeholderstringPlaceholder text.
requiredbooleanfalseMarks the field required (adds a marker).
disabledbooleanfalseDisable the field.
readonlybooleanfalseNative readonly — value visible but not editable; rendered muted.
invalidbooleanApply invalid styling + aria-invalid (also implied by `error`).
hintstringHelper text rendered under the input and wired via aria-describedby.
errorstringError text under the input; implies aria-invalid and is announced to AT.
describedbystringid(s) of additional describing element(s) (aria-describedby).
prefixSnippetDecorative leading content inside the field, before the input.
suffixSnippetDecorative trailing content inside the field, after the input.
clearablebooleanfalseRenders a clear button; hidden when empty/readonly/disabled.
autocompleteFullAutoFillNative autocomplete hint.
inputmodeHTMLInputAttributes['inputmode']Native inputmode hint for on-screen keyboards.
maxlengthnumberNative maxlength.
oninput(e) => voidInput handler.
size'sm' | 'md' | 'lg'Per-instance size override; inherits the ancestor `data-size-variant` when unset.
...restHTMLInputAttributesAny remaining native input attributes / handlers are forwarded.