# Repeatable rows

A list of fields that a person can add to and remove from, such as skills or languages.

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/repeatable-rows shows the Dex app's own React component, which only works inside the Dex codebase.

## HTML

`dex.css` has no class for the list: it's ordinary fields in rows, each with a ghost remove button at its end, and one ghost button under the list that adds a row.

```html
<fieldset class="dex-form-row" style="border: 0; margin: 0; padding: 0">
  <legend class="dex-field-label">Skills</legend>
  <div style="display: flex; flex-direction: column; gap: 0.5rem">
    <div style="display: flex; align-items: center; gap: 0.5rem">
      <input class="dex-field" aria-label="Skill 1" value="PyTorch" />
      <button class="dex-button dex-button--ghost" style="width: 2.25rem; padding: 0; flex-shrink: 0; color: var(--dex-muted-foreground)" aria-label="Remove skill 1">
        <svg aria-hidden="true"><!-- Lucide trash-2 --></svg>
      </button>
    </div>
    <div style="display: flex; align-items: center; gap: 0.5rem">
      <input class="dex-field" aria-label="Skill 2" placeholder="e.g. Python" />
      <button class="dex-button dex-button--ghost" style="width: 2.25rem; padding: 0; flex-shrink: 0; color: var(--dex-muted-foreground)" aria-label="Remove skill 2">
        <svg aria-hidden="true"><!-- Lucide trash-2 --></svg>
      </button>
    </div>
    <button class="dex-button dex-button--ghost" style="align-self: flex-start; margin-top: 0.25rem">
      <svg aria-hidden="true"><!-- Lucide plus --></svg>
      Add skill
    </button>
  </div>
</fieldset>
```

- **Two fields per row**: put the two fields side by side in the row (`flex: 1` each, 16px apart, stacking on a phone), with a row of `dex-field-label` column labels above the first row; each field takes `aria-labelledby` pointing at its column label.
- **Row error**: `aria-invalid="true"` on the field it's about, and a `dex-field-error` with `role="alert"` under that row only: "Enter a language."

## Rules

- Name every field. With one field per row, the legend names the group and each input takes an `aria-label` such as "Skill 2".
- An error belongs to its row, never to the whole list.
- When a list starts with one empty row, leave out that row's remove button until there's something to remove. In two-field rows keep it, so the fields stay under their column labels.
- When adding or removing takes away the button that was pressed, move focus into a row's input so it isn't lost.
