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
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | - | Required. Wires label and messages. |
label | string | - | Visible label text. |
name | string | id | Form field name. |
type | string | text | Native input type. |
hint | string | - | Help text below the input. |
error | string | - | Error message; sets aria-invalid. |
required | boolean | false | Marks and enforces required. |
disabled | boolean | false | Non-interactive. |
readonly | boolean | false | Read-only. |
size | sm | md | lg | md | Control height and font size (TextField, NumberInput, PasswordInput, SearchInput, Textarea; Select uses controlSize). |
Theming
:root {
--ink-input-radius: 0.25rem;
--ink-input-border: #d6cec3;
}Accessibility
- Label is a real
<label for>, hint and error connect viaaria-describedby. - Error state sets
aria-invalid="true". - Focus shows a border + soft ring; the outline is replaced, not removed.
- Disabled inputs keep 3:1 contrast on their border.