Skip to content

TextField

Single-line text input with label, hint, and error wiring handled for you. Every other text-like input in astro-ink builds on this pattern.

Basic with hint

We only use it for the receipt.

<TextField
  id="email"
  label="Email"
  type="email"
  hint="We only use it for the receipt."
  placeholder="you@example.com"
/>

Error state

That username is taken.

<TextField id="username" label="Username" error="That username is taken." />

Sizes

<TextField id="size-sm" label="Small" size="sm" />
<TextField id="size-lg" label="Large" size="lg" />

Disabled and readonly

<TextField id="plan" label="Plan" value="Team" disabled />
<TextField id="ref" label="Reference" value="INK-0117" readonly />

Props

PropTypeDefaultDescription
idstring-Required. Wires label and messages.
labelstring-Visible label text.
namestringidForm field name.
typestringtextNative input type.
hintstring-Help text below the input.
errorstring-Error message; sets aria-invalid.
requiredbooleanfalseMarks and enforces required.
disabledbooleanfalseNon-interactive.
readonlybooleanfalseRead-only.
sizesm | md | lgmdControl height and font size (TextField, NumberInput, PasswordInput, SearchInput, Textarea; Select uses controlSize).

Theming

:root {
  --ink-input-radius: 0.25rem;
  --ink-input-border: #d6cec3;
}

Accessibility