# Chips

Short, label-only answers to a question, where one or several can be chosen.

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

## HTML

A chip is a pill button with `aria-pressed`, or a label round a hidden radio or checkbox. Chosen, it fills primary.

```html
<fieldset style="border: 0; margin: 0; padding: 0">
  <legend class="dex-field-label" style="margin-bottom: 0.75rem">How do you like to work?</legend>
  <div style="display: flex; flex-wrap: wrap; gap: 0.5rem">
    <label class="dex-chip"><input type="radio" name="mode" /> Remote</label>
    <label class="dex-chip"><input type="radio" name="mode" checked /> Hybrid</label>
    <label class="dex-chip"><input type="radio" name="mode" /> In the office</label>
  </div>
</fieldset>
```

- **Multiple choice**: checkboxes in place of radios, or buttons with `aria-pressed` you toggle yourself. In the app each chip leads with a plus that becomes a tick when chosen, so it never changes width. `dex.css` doesn't draw those; add a Lucide `plus` or `check` `<svg width="16" height="16">` before the label.

```html
<button class="dex-chip" aria-pressed="true">
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5" /></svg>
  Backend
</button>
```

- **Small**: `dex-chip--sm` is 32px tall, for chat. The default 40px is for forms.
- **Other reveals an input**: a full-width `dex-field` 8px below the chips when "Other" is chosen.
- **Actions in a chip row** ("More", "Something else"): plain `<button class="dex-chip">` with no `aria-pressed`, after the answers. They're never on.
- **Quick replies** above a message box: plain chip buttons that send the reply at once. **Starters** lead with a Lucide `pencil` and fill the message box with the start of a reply.
- **Invalid**: `aria-invalid="true"` on every chip in the group (or on each chip's input) turns them all red, with one `dex-field-error` under the group: "Choose at least one option."
- **Disabled**: `disabled` on the chip button or its input fades it to 50% on a muted fill; a chosen chip keeps its primary fill.

## States

- Rest, hover and focus step the edge from 25% to 50% to 75%. Chosen, it fills primary; on focus a 1px line shows just inside its edge.

## Rules

- Use chips for short answers that need no explanation. An option that needs a sentence is a choice card.
- A chip is always a pill, so it never reads as a button.
- Without a visible question, give the group an `aria-label`.
- A chip that does something rather than being an answer is a plain button, never pressed.
- Selected is primary, never orange.
