Aliases
input, text input
components / textfield
Single-line field shell with DK field tokens, helper/error support, and leading/trailing slots.
Playground
Start here. Switch systems, interact with the shipped component, and let the rest of the page answer the why and how after the behavior clicks.
Cobalt
The crisp default DK action system: bright primary, roomy spacing, and a direct editorial rhythm.
Overview
This section explains the intent of the component before the implementation details.
Aliases
input, text input
Explore the math
Type and Scale,Spacing,Contrast and Distinctness,Proof System
Decision guide
Use these notes to decide quickly whether this is the right DK component for the job.
Decision guide
Do
Do not
Usage
Prefer these situations when choosing this component.
Usage
These patterns are better served by a different component or a simpler surface.
Anti-patterns
Migration notes
Anatomy
The anatomy explains which pieces matter to the recipe and accessibility model.
field wrapper
rootOwns label, helper text, error text, and control grouping.
field label
labelNames the input clearly.
native text input
controlSingle-line input element using DK field tokens.
supporting slot
leadingOptional prefix or icon before the value.
supporting slot
trailingOptional suffix or small status marker after the value.
API
The docs contract distinguishes props, DOM events, and slots so integration behavior is explicit.
Props
| Name | Type | Default | Description |
|---|---|---|---|
label | string | — | Visible label used for the field or control. |
description | string | — | Supporting helper copy rendered below or beside the main label. |
error | string | — | Validation or problem copy rendered in the error slot when present. |
placeholder | string | — | Placeholder text shown before a user makes a selection or enters text. |
required | boolean | false | Marks the field or control as required for form semantics and docs examples. |
disabled | boolean | false | Disables interaction and exposes the correct non-interactive semantics for the control. |
name | string | — | Form field name used for native form submission. |
id | string | — | Optional id used to bind external labels or descriptions to the component. |
size | 'sm' | 'md' | 'lg' | 'md' | Chooses the compiled size recipe for the component. |
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 | undefined }) => void | — | Callback fired when the value changes. |
theme | ThemeContract | — | Overrides the compiled DK theme used to resolve tokens and recipes for this component. |
Events
| Name | Payload | Description |
|---|---|---|
change | { value: string | undefined } | Fires when the component commits a new value. |
Slots
| Name | Description |
|---|---|
leading | Optional prefix or icon. |
trailing | Optional suffix or status marker. |
Recipes
These notes summarize the intended recipe surface rather than exposing raw implementation detail first.
Variants
Sizes
States
Accessibility
This is the behavior the component promises to assistive tech and keyboard users today.
Semantics
Keyboard
Screen readers
Checklist
Implementation
This section shows the representative compiled slot variables that the runtime consumes for the selected design system.
Implementation notes
Implementation checklist
Examples
Each example is intentionally practical, grouped by starter, common pattern, and edge-case coverage.
Starter
1 example
starter
Starter: labeled single-line inputA basic project-name input with helper text.
Copy snippet
<TextField label="Project name" description="Use a short name the team can scan quickly." placeholder="Launch roadmap" />Common patterns
1 example
common
Common: prefixed metadata fieldLeading and trailing slots help compact metadata entry without custom chrome.
Copy snippet
<TextField label="Project key" placeholder="APOLLO"><svelte:fragment slot="leading">#</svelte:fragment><svelte:fragment slot="trailing">ok</svelte:fragment></TextField>Edge cases
1 example
edge
Edge: inline validationUse the error slot when the field needs explicit corrective feedback.
Copy snippet
<TextField label="Project name" error="A project name is required." placeholder="Launch roadmap" />Verification
Proofs stay visible in the docs so the system shows what it can guarantee, not just what it can render.
size=xs
size=sm
size=md
size=lg
size=md
size=sm