Forms

Input

Single-line text input with bound value, label, description, and error wiring for form-field accessibility.

import { Input } from '@lostgradient/cinder';
formfield
01

Overview

Reference usage

Single-line text input with support for labels, addons, validation states, and helper text.

On touch, the field is at least 44px tall. With an addon, tapping the top or bottom border over the text field focuses the input.

Usage

svelte
<script lang="ts">
  import { Input } from '@lostgradient/cinder';

  let name = $state('');
</script>

<Input id="field" bind:value={name} label="Full name" placeholder="Jane Smith" />
{#if name}
  <p style="margin-top: 0.5rem; color: var(--cinder-text-muted);">Hello, {name}!</p>
{/if}

Filled appearance

appearance="filled" draws an inset fill inside the same 1px --cinder-control-border edge, a 12px radius and the 2px focus ring. The edge is what keeps the 3:1 boundary: the fill alone measures about 1.1:1 against its surface and would fail WCAG 1.4.11. Hover darkens the edge, focus lifts the fill to the control surface under the ring, an invalid field keeps its danger edge, and a disabled field drops to the disabled fill. A read-only value drops the fill and keeps its dashed edge, so an editable field and a read-only value stay apart. Under data-density="comfortable" a field with no appearance is filled and 48px tall; the default density stays outlined, and appearance="outlined" opts a field out. The same prop is on Select, Textarea and SearchField.

svelte
<script lang="ts">
  import { Input } from '@lostgradient/cinder';

  let email = $state('');
</script>

<Input id="email" appearance="filled" bind:value={email} label="Email" />
Live preview

Basic input

02

When to use

Use when
  • Collecting a single line of free-form text such as a name, email, or URL.
  • Composing inside a form-field with leading or trailing adornments while keeping the input at least 44px tall on touch.
Avoid when
  • Collecting multi-line prose — use textarea instead.
  • Collecting a numeric value with stepping controls — use number-input instead.
03

Examples

Basic input

Text input with label and bound value.

Code variant

variant="code" applies a shared monospace metric set for source-like values such as regular expressions, URIs, or identifiers.

Compact field with hidden label

Keep the accessible name from label while visually hiding it for compact auth/token layouts.

Editable title

variant="bare" is text that looks like a 600-weight title and is edited in place: no border at rest, a hover tint, and the control fill under the focus ring.

Newsletter signup

An email-capture section recipe: a form pairs Input with a submit Button inside a raised panel, with heading copy and a consent line.

Sign-in composition

Composition of FormField + Input + Button with a top-of-form Alert auth-error region. Demonstrates the required autocomplete values and the assertive announcement pattern via role="alert".

Input types

Text, email, password, search, date, tel, and url types.

Input with error

Error message wired via aria-invalid and aria-describedby.

04

Props

Props for input
Name
Type
Default
Description
id required text HTML id for the underlying input, used to associate the <label> and ARIA attributes. Required.
value bindable text '' Bindable current text value of the input.
onValueChangeRequest (next: string) => stringvoid Intercept a proposed value before the bindable value is written. Return a replacement value to transform it.
onValueChange (next: string) => void Notify after the bindable value has been committed.
label text Visible label text rendered above the input and linked via for/id.
labelVisible boolean true Whether the label is visibly rendered. Set false to visually hide it while keeping it programmatically associated.
description text Helper text rendered below the input and associated via aria-describedby.
descriptionAction snippet Rendered after the helper text inside the same paragraph, so it joins aria-describedby: a quiet link such as "Where do I get one?". Shown only with description.
error text Error message rendered below the input; also sets aria-invalid on the input.
disabled boolean When true, disables the input, matching the native disabled attribute.
required boolean Marks the input as required for form validation, matching the native required attribute.
optional boolean false Appends "Optional" to the visible label. Do not combine with required; required wins.
type 'text''email''password''search''tel''time''url''date'
1 more members 'number'
'text' Input type controlling the browser's built-in validation and keyboard. Default "text".
variant 'default' | 'code' | 'bare' 'default' Visual style. "code" applies a shared monospace metric set (font-family, font-size, line-height, tab-size) for source-like values such as regular expressions, URIs, or identifiers. "bare" is an editable title: text that looks like a 600-weight title, with no border at rest, a hover tint, a focus ring over the control fill, and a width that follows its content.
appearance 'outlined' | 'filled' | undefined How the field is drawn. "outlined" is the control fill inside a 1px edge. "filled" is an inset fill inside the same 1px --cinder-control-border edge, which keeps the 3:1 boundary the fill alone would lose, with a 12px radius, a 48px height in the comfortable density and the 2px focus ring. Left unset, the field follows its density: filled under data-density="comfortable", outlined otherwise.
quietBorder boolean false Uses Cinder's opt-in quiet resting boundary for an outlined control in a dense settings surface. It remains at least 3:1 against both adjacent surfaces; hover, focus, invalid, disabled, and high-contrast states keep their standard treatments.
size 'sm' | 'md' | 'lg' 'md' Height step from the shared --cinder-control-height-* scale: sm 28px, md 32px, lg 40px, the same heights as a Button of that size. Replaces the native character-width size attribute, which Cinder does not forward; set a width with CSS instead.
inputAttachment Attachment<HTMLInputElement> Attachment for native input access and lifecycle-scoped listeners.
groupClassName text Additional class names applied to the grouped control frame when leading or trailing content is present.
leading snippet
trailing snippet
leadingInteractive boolean false When true, the leading adornment is interactive and included in the accessibility tree. Default false.
trailingInteractive boolean false When true, the trailing adornment is interactive and included in the accessibility tree. Default false.
oninput FormEventHandler<T> | undefined | null