# Text input

> One line of text with a visible label, an optional hint and a plain-language error.

Source: https://kwark.space/designSystem/components/text-input

## Usage

### What it is
A single line the person types into. Kwark’s current field is the story-surface one used in dialogs and the production office: a 36px box on a step of the ground, a 1px line, and the project’s light accent on the border when focused. Labels are sentence case, above the field.

### Variants
| Variant | Where | Notes |
|---|---|---|
| Field | Date editor (*What*, *Where*), project dialogs | 36px, 14px text |
| Numbers | Runtime, *How many* days in the date editor | `kw-input--mono`: tabular figures |
| Search | Home’s *Find a story…* | 44px box, the glyph inside, no label but an `aria-label` |

### Writing
- Label with the noun the person thinks in: *What*, *Where*, *Who it is for*.
- Placeholders show an example, never the label: *Costume fitting, Meera*, *Draft to the producer*.

### Moving older code over
`Input.tsx` draws a 12px upper-case tracked label and an 8px-cornered box with a ring. The production office draws upper-case labels too (`.po-label`). The system uses the story dialog’s sentence-case label; change the label when a file is touched.

## Style

### Anatomy

1. **Label**: Poppins 500, 12px, `--k-text`, 6px above the field.
2. **Box**: at least 36px, 7px 10px padding, 6px corners, 1px `--k-line`, ground `color-mix(--k-surface 35%, --k-bg)`.
3. **Text**: Poppins 400, 14px; placeholder `--k-text-2` at 65%.
4. **Focus**: border `--k-accent-soft`; keyboard focus adds a 2px ring in the same colour.
5. **Invalid**: border `--k-danger` and an error line under it in 12px.
6. **Read-only**: dashed border, no ground (ReadOnlyModule makes fields read-only for viewers).

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-surface` | #ffffff | #1a1a1a |
| `--k-line-strong` | var(--k-text-2) | var(--k-text-2) |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-danger` | #b4382c | #e0685c |
| `--k-focus` | #0f172a | #f4f4f5 |
| `--k-radius-control` | 6px |  |
| `--k-control-md` | 36px |  |

## Code

### React

In the Kwark app: `import Input from '@/components/ui/Input'`.

```tsx
<Input label="Scene heading" value={heading} onChange={e => setHeading(e.target.value)} />
```

| Prop | Type | Notes |
|---|---|---|
| `label` | `string` | always visible; never placeholder-only |
| `icon` | `LucideIcon` | leading icon |

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<label class="kw-field" style="width:100%;max-width:360px"><span class="kw-label">What</span><input class="kw-input" value="Costume fitting, Meera"><span class="kw-hint">What happens on this date.</span></label>
<label class="kw-field" style="width:100%;max-width:360px"><span class="kw-label">Est. runtime (min)</span><input class="kw-input kw-input--mono" inputmode="numeric" value="90"></label>
<label class="kw-search" style="width:100%;max-width:360px"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg><input aria-label="Search projects" placeholder="Find a story…"></label>
```

## Accessibility

- Tie hint and error to the field with `aria-describedby`; set `aria-invalid="true"` on error.
- Never remove the focus ring.
- Keep the field 16px or larger on iOS, or Safari zooms the page.

## For agents

### Rules

- **Must** show a visible label; never use placeholder text as the label.
- **Must** write errors that say what happened and how to fix it.
- **Always** link hints and errors with `aria-describedby`.

### AI readiness test

**Task:** Build the "New location" form: name, address, contact, notes.

**Give the agent:** Text input, Textarea, Forms pattern, Content and voice.

**Constraint:** Do not invent validation rules that are not stated.

**A reliable answer:**
- Visible labels
- Only name required, marked in words
- Errors that name the fix
- Primary "Add location"
