# Input

A single line of text, such as a job title, an email address, a URL or a number.

This is the HTML to build it with `dex.css`, for work outside the Dex codebase. Read https://brand.meetdex.ai/design.md first: it says how to set up a page and how to use the stylesheet. The page at https://brand.meetdex.ai/components/input shows the Dex app's own React component, which only works inside the Dex codebase.

## HTML

An input sits in a field: a label, the control, then helper text or an error, 6px apart.

```html
<div class="dex-form-row">
  <label class="dex-field-label" for="title">Current job title</label>
  <input class="dex-field" id="title" placeholder="Senior backend engineer" aria-describedby="title-help" />
  <span class="dex-field-help" id="title-help">As it appears on your CV</span>
</div>
```

- **Optional**: add "(optional)" after the label in muted text: `<label class="dex-field-label" for="site">Personal site <span class="dex-muted">(optional)</span></label>`.
- **Invalid**: `aria-invalid="true"` turns the edge red, and a `dex-field-error` with `role="alert"` takes the helper text's place. See https://brand.meetdex.ai/components/errors.md.
- **Disabled**: the `disabled` attribute. Dim the label with it (`style="opacity: 0.5"` on the label).
- **Read-only**: a value that can be read and copied but not changed here. The text keeps full contrast, with a muted fill and a lock at the end. `dex-field` with `readonly` gives the fill but no lock, so for the lock use a joined field:

```html
<div class="dex-form-row">
  <label class="dex-field-label" for="salary">Current salary</label>
  <span class="dex-joined">
    <input id="salary" value="£88,000" readonly aria-describedby="salary-help" />
    <span class="dex-joined-text"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="18" height="11" x="3" y="11" rx="2" ry="2" /><path d="M7 11V7a5 5 0 0 1 10 0v4" /></svg></span>
  </span>
  <span class="dex-field-help" id="salary-help">From your CV</span>
</div>
```

- **With a prefix, unit or icon inside the border** (£, "a year", a search icon): see https://brand.meetdex.ai/components/joined-field.md.

## States

- Rest, hover and focus step the edge from 25% to 50% to 75%. Focus is a 1px edge inside the field, never a glow.
- Invalid keeps its red edge on focus, doubled.

## Rules

- Every input has a label joined to it with `for` and `id`, and its helper text or error joined with `aria-describedby`.
- Write an error as one sentence that says what to do: "Enter your work email.", "Enter a URL like https://github.com/you.". Never "Please", "required", "invalid" or "This field".
- Give a read-only input helper text saying where the value came from.
- The text is 16px at every screen size and the field 44px tall, so a phone doesn't zoom in. Leave them at that size.
- Use the right `type` and `autocomplete` (`email`, `url`, `tel`), and `inputmode="numeric"` for figures.
