# Select

Picks one answer from a short, fixed list, such as a notice period.

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

## HTML

The simplest select is a native one: `dex.css` draws its field and chevron, and the list is the browser's own.

```html
<div class="dex-form-row">
  <label class="dex-field-label" for="notice">Notice period</label>
  <select class="dex-field" id="notice">
    <option value="" disabled selected>Choose a notice period</option>
    <option>2 weeks</option>
    <option>1 month</option>
    <option>3 months</option>
  </select>
</div>
```

- **The app's own list** (a prototype or a mock that shows it open): a `dex-field-button` that opens a `dex-listbox`, 4px under it and at least as wide, with a tick on the chosen option. Show and hide the popover with `hidden`, and set `aria-expanded` to match.

```html
<div class="dex-popover-anchor">
  <button type="button" class="dex-field dex-field-button" aria-haspopup="listbox" aria-expanded="true" aria-label="Notice period">
    <span>1 month</span>
  </button>
  <div class="dex-popover dex-popover--list">
    <div class="dex-listbox" role="listbox" aria-label="Notice period">
      <div class="dex-menu-item" role="option">2 weeks</div>
      <div class="dex-menu-item" role="option" aria-selected="true">1 month</div>
      <div class="dex-menu-item" role="option">3 months</div>
    </div>
  </div>
</div>
```

- `dex-field-button` has no chevron of its own. Add a Lucide chevron-down `<svg>` as its last child, with `style="margin-left: auto"`.
- **Invalid**: `aria-invalid="true"` on the select or the button, with a `dex-field-error` under it.
- **Disabled**: the `disabled` attribute.
- **Read-only**: a native select ignores `readonly` and still opens. Use a `dex-field-button` with `aria-readonly="true"` instead: a muted fill, no list, and a lock in the chevron's place. Give it helper text saying why.

## Rules

- Use a select for one answer from a short, fixed list. For a longer list that needs a search, use a combobox (https://brand.meetdex.ai/components/combobox.md).
- The placeholder says what to do ("Choose a notice period"); the chosen option shows its label.
- The chosen option gets a tick at its end. The grey fill only follows the pointer or keyboard.
- The list opens under the field, lined up with its start and at least as wide.
