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
/>

HTML

interactive with vanilla.js The exact markup the component renders, generated at build time. Use it with dssoca/vanilla.css+ dssoca/vanilla.js — see Plain HTML & CSS.

html
<div class="ss-field">
  <label class="lbl" for="q">Search</label>
  <div class="control">
    <input class="ss-input" id="q" type="text" value="query" placeholder="Search…"/>
    <button type="button" class="clear" aria-label="Clear">×</button>
  </div>
</div>

vanilla.js wires the clear button (empties, refocuses, hides itself until you type).

Props

PropTypeDefaultDescription
labelstring—Visible label (associated via generated id).
valuestring''Bindable value.
typestring'text'Native input type.
placeholderstring—Placeholder text.
requiredbooleanfalseMarks the field required (adds a marker).
disabledbooleanfalseDisable the field.
readonlybooleanfalseNative readonly — value visible but not editable; rendered muted.
invalidboolean—Apply invalid styling + aria-invalid (also implied by `error`).
hintstring—Helper text rendered under the input and wired via aria-describedby.
errorstring—Error text under the input; implies aria-invalid and is announced to AT.
describedbystring—id(s) of additional describing element(s) (aria-describedby).
prefixSnippet—Decorative leading content inside the field, before the input.
suffixSnippet—Decorative trailing content inside the field, after the input.
clearablebooleanfalseRenders a clear button; hidden when empty/readonly/disabled.
autocompleteFullAutoFill—Native autocomplete hint.
inputmodeHTMLInputAttributes['inputmode']—Native inputmode hint for on-screen keyboards.
maxlengthnumber—Native maxlength.
oninput(e) => void—Input handler.
size'sm' | 'md' | 'lg'—Per-instance size override; inherits the ancestor `data-size-variant` when unset.
...restHTMLInputAttributes—Any remaining native input attributes / handlers are forwarded.
↑↓ navigate · ↵ open · esc close

Keyboard shortcuts

No shortcuts registered

Shortcuts added through the dssoca registry will show up here.

Single-key shortcuts