# Field

> Labelled text input with hint/error wiring and an accent focus ring.

- Group: Core
- Status: stable
- Aliases: input, text-field
- HTML page: https://design.ipmnx.com/components/field/
- Spec: https://design.ipmnx.com/design/#nx-field

## Preview

**Label + placeholder**

```html
<label class="nx-field">
  <span class="nx-field__label">Search jobs</span>
  <input class="nx-field__input" placeholder="Type to filter…">
</label>
```

```tsx
<NxField label="Search jobs" placeholder="Type to filter…" />
```

## API

### React props (NxKit)

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `label` | `string` |   | yes | Field label text. |
| `placeholder` | `string` | `undefined` |   | Input placeholder. |
| `hint` | `ReactNode` | `undefined` |   | Help text under the input (aria-describedby). |
| `error` | `ReactNode` | `undefined` |   | Error under the input; sets aria-invalid. |

### Classes

| Class | Description |
| --- | --- |
| `.nx-field` | Label wrapper |
| `.nx-field__label` | .72rem/560, slate-500 |
| `.nx-field__input` | Input: hairline border, 10px radius, accent focus ring |
| `.nx-field__hint` | Muted helper text, wire via aria-describedby |
| `.nx-field__error` | Danger helper text, wire via aria-describedby + aria-invalid |

## States

### invalid

```html
<label class="nx-field"><span class="nx-field__label">Invalid</span><input class="nx-field__input" aria-invalid="true" aria-describedby="err-email" value="nord@"></label><span class="nx-field__error" id="err-email"><span aria-hidden="true">✕</span> Enter a valid email address</span>
```

### disabled

```html
<label class="nx-field"><span class="nx-field__label">Disabled</span><input class="nx-field__input" value="Locked" disabled></label>
```

### readonly

```html
<label class="nx-field"><span class="nx-field__label">Read-only</span><input class="nx-field__input" value="#4412" readonly></label>
```

### hint

```html
<label class="nx-field"><span class="nx-field__label">With hint</span><input class="nx-field__input" aria-describedby="hint-note" placeholder="Note…"></label><span class="nx-field__hint" id="hint-note">Only visible to your team.</span>
```

## Accessibility

- Invalid inputs set aria-invalid="true" + aria-describedby pointing at the .nx-field__error id. The error must already exist in the DOM, not be conditionally unmounted before the describedby read.
- Focus replaces the browser default outline with an accent border + glow. Never remove focus styling without an equivalent.

## Do / Don't

- Do: Always wrap the input in a `<label>` (or pair an explicit htmlFor).
- Don't show the error text without also setting aria-invalid + aria-describedby on the input.

## Related

- [Textarea](https://design.ipmnx.com/components/textarea.md)
- [Select](https://design.ipmnx.com/components/select.md)

---

Source: registry.js (NX Design System)
