# Shadows and hairline

Four steps of shadow for surfaces that sit above the page, four edge shadows for bars pinned to the screen, and the one line width used for every edge and divider.

This is the rule in `dex.css` terms, 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/shadows shows the rule on the Dex app's own React components, which only work inside the Dex codebase.

## HTML

Every `dex-` surface already has its shadow (`dex-card` has `sm`; `dex-menu`, `dex-popover`, `dex-dialog` and `dex-toast` have `lg`). For anything you draw yourself, take it from a token:

| Token | Use |
| --- | --- |
| `--dex-shadow-xs` | An edge with no lift: the hairline drawn inside the box, so it adds no width |
| `--dex-shadow-sm` | A card |
| `--dex-shadow-md` | Something pinned over the page, such as a sticky bar |
| `--dex-shadow-lg` | An overlay: menus, popovers, dialogs, toasts |
| `--dex-shadow-edge-b`, `-t`, `-l`, `-r` | A bar or panel pinned to an edge of the screen. The shadow falls the way its letter says: `edge-b` falls below a bar pinned to the top |
| `--dex-hairline` | The one line width: 1px, and 0.5px on retina screens |

```html
<header style="position: sticky; top: 0; background: var(--dex-background);
  box-shadow: var(--dex-shadow-edge-b); border-bottom: var(--dex-hairline) solid var(--dex-border)">…</header>
<hr class="dex-rule" />
```

## Rules

- A shadow says how far a surface is lifted off the page: `sm` for a card, `md` for something pinned over the page, `lg` for an overlay.
- Every step includes the hairline edge, so a surface with a shadow needs no border as well. Menus, popovers and dialogs have `lg` and no border.
- A bar pinned to an edge takes the `edge-*` shadow that falls away from that edge, and a hairline border on its inner side only.
- Lines and dividers are `--dex-hairline` in `--dex-border`. Nothing is thicker, except a focus or selection edge. A divider between sections is `dex-rule`, which fades at both ends.
- Never write a drop shadow by hand. A ring with no blur that draws an edge or a state, such as a focus line, is a border: write it as an inset `box-shadow` with its colour from a token.
- The steps and the line width are the same in light and dark.
