Aliases
input, text input
TextFieldSingle-line input with labels, guidance, errors, and icon slots.
Aliases
input, text input
Foundations
Type and scale,Spacing,Contrast and distinctness,Proof system
TextField for short text input like names, labels, identifiers, and small metadata values.TextField for multiline text; use Textarea.field wrapper
root Owns label, helper text, error text, and control grouping.
field label
label Names the input clearly.
native text input
control Single-line input element using DK field tokens.
supporting slot
leading Optional prefix or icon before the value.
supporting slot
trailing Optional suffix or small status marker after the value.
| Name | Type | Default | Description |
|---|---|---|---|
label | string | — | Visible label used for the field or control. |
description | string | — | Provides field guidance associated with the control. |
error | string | — | Shows a validation error associated with the control. |
placeholder | string | — | Placeholder text shown before a user makes a selection or enters text. |
required | boolean | false | Marks the control as required. |
disabled | boolean | false | Prevents interaction and exposes the disabled state. |
name | string | — | Form field name used for native form submission. |
id | string | — | Sets the control ID for external labels and descriptions. |
size | 'sm' | 'md' | 'lg' | 'md' | Sets the component size. |
readonly | boolean | false | Keeps the field focusable while preventing edits. |
type | string | 'text' | Native input type. |
value | string | — | Controlled text value. |
onChange | (detail: { value: string }) => void | — | Runs when the value changes. |
theme | ThemeContract | — | Sets the theme used to resolve component styles. |
| Name | Payload | Description |
|---|---|---|
change | { value: string } | Fires with the text value. |
| Name | Description |
|---|---|
leading | Optional prefix or icon. |
trailing | Optional suffix or status marker. |
Variants
default: TextField uses one structural field shell and varies mainly by size and state.Sizes
sm: Compact field shell for denser tools.md: Default field size for general product use.lg: Larger field shell for spacious or touch-oriented layouts.States
rest: Default field shell.focus-visible: Focused input with a visible outline.invalid: Validation state with error messaging.disabled: Semantically disabled and visibly muted.Semantics
Keyboard
Screen readers
Checklist
A basic project-name input with helper text.
<TextField label="Project name" description="Use a short project name." placeholder="Launch roadmap" /> Use leading and trailing slots for prefixes, units, or status markers.
<TextField label="Project key" placeholder="APOLLO"><svelte:fragment slot="leading">#</svelte:fragment><svelte:fragment slot="trailing">ok</svelte:fragment></TextField> Set the error prop to explain a validation failure.
<TextField label="Project name" error="A project name is required." placeholder="Launch roadmap" /> Calculated fixtures; browser evidence is not collected. Layout estimates use declared text behavior and maximum token values.
size=xs
size=sm
size=md
size=lg
size=md
size=sm