# Button

Starts an action, such as saving a form or opening a dialog.

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

## HTML

```html
<button class="dex-button dex-button--brand">Ask Dex</button>
<button class="dex-button">Save changes</button>
<button class="dex-button dex-button--outline">Cancel</button>
<button class="dex-button dex-button--secondary">Filters</button>
<button class="dex-button dex-button--ghost">Back</button>
<button class="dex-button dex-button--destructive">Withdraw</button>
<button class="dex-button dex-button--link">Show 4 more</button>
```

- **Variants**: `dex-button` alone is primary black. `--brand` is the one orange action on a screen, `--outline` is secondary, `--secondary` is a quiet toolbar control, `--ghost` is tertiary, `--destructive` only confirms a destructive step, and `--link` is a text button with a button's place in a row ("Show 4 more").
- **Sizes**: `--sm` (32px), the default (36px), `--lg` (40px) and `--xl` (48px, hero calls to action only). There are no others.
- **With an icon**: put a Lucide `<svg>` before the label, or after it when it points where the action leads. The button sizes it to 16px.

```html
<button class="dex-button dex-button--outline">
  <svg aria-hidden="true"><!-- Lucide plus --></svg>
  Add role
</button>
```

- **Icon only**: give it an `aria-label` and make it square with layout CSS of your own: `style="width: 2.25rem; padding: 0"` (2rem for `--sm`, 2.5rem for `--lg`). Ghost or outline, never brand.
- **As a link**: navigation is an `<a class="dex-button">` with an `href`, so it's a real link.
- **Disabled**: the `disabled` attribute, or `aria-disabled="true"` on a link. It fades to 50%.

## States

- Hover: solid buttons (default, brand, destructive) go to 85%, secondary to 80%, outline steps its edge up, ghost takes a faint fill, link underlines.
- Focus: a solid button draws a 1px line in its text colour just inside its edge; the quiet ones take the 75% control edge. No glow, nothing outside the button.

## Rules

- One orange (`--brand`) button per screen, for the main conversion only. Everything else is black or quieter.
- Name what happens, in sentence case with no full stop: "Save changes", "Start application". Never "OK", "Submit", "Get started" or "Learn more".
- Keep a form's main button active. When it's pressed with something missing, show the error on the field; never disable it to say something is missing.
- Loading: `dex.css` has no spinner. Change the label to say what's happening ("Sending…") and set `aria-disabled="true"` until it finishes, so it can't be pressed twice.
- `dex.css` has no sign-in buttons. Draw another product's logo only from a file you were given (design.md, "Product UI mocks").
