<!-- Hand-written file, copied to /ai/recipes.md at build time. The generator runs the
strict class check on every HTML block below and fails the build when one uses a class
that does not exist: keep the examples small and complete. -->

# Recipes - from a layout intent to markup

The catalog is organised by component; design work starts from an intent ("a grid of
cards", "a muted helper text"). Each recipe below gives the composition to start from.
Read the file of every component you use for its other modifiers:
[components-index.md](/ai/components-index.md).

A recipe composes components only when no single component does the job: check the
higher levels first ([Architecture](/ai/components-index.md#architecture-atomic-design)).
The space between components comes from two layout organisms - never from custom CSS:

- [vertical-spacing](/ai/components/vertical-spacing.md) stacks `--line`s with a gap `-s<n>`;
- [horizontal-spacing](/ai/components/horizontal-spacing.md) puts `--column`s side by side
  with a gap `-s<n>`.

`--line` and `--column` must be direct children of their block. Use a spacing block only
between components that nothing else places: a single component needs none, and the
elements of a component are placed by the component itself - never wrap them (the label
and input of an `araxxe-field`, the value and caption of an `araxxe-label-legend`, the
rows of an `araxxe-table-details`).

## Page with a navigation

Start from a shell of [page-skeleton.md](/ai/page-skeleton.md). The header has no text
tabs: page navigation goes in the menu, under the header, and `-selected` marks the
current page.

```html
<nav class="araxxe-menu">
  <ul class="araxxe-menu--content">
    <li class="araxxe-menu--slot">
      <button class="araxxe-button-menu">
        <span class="araxxe-button-menu--icon araxxe-glyph-home"></span>
        <span class="araxxe-button-menu--text">Overview</span>
      </button>
    </li>
    <li class="araxxe-menu--slot">
      <button class="araxxe-button-menu -selected">
        <span class="araxxe-button-menu--icon araxxe-glyph-list"></span>
        <span class="araxxe-button-menu--text">Rules</span>
      </button>
    </li>
  </ul>
</nav>
```

## Page title with a muted subtitle

`-s5` keeps a title and its subtitle together; use `-s30` between the sections of a page.
The page shells already put an `<h1>` in the header (`araxxe-title-header`): keep a
single `<h1>` per page and use `<h2>` here. The title classes style any heading tag.

```html
<div class="araxxe-vertical-spacing -s5">
  <div class="araxxe-vertical-spacing--line">
    <h2 class="araxxe-title-big">Teams and rules</h2>
  </div>
  <div class="araxxe-vertical-spacing--line">
    <p class="araxxe-paragraph -color-shade-50">How the office is shared between teams.</p>
  </div>
</div>
```

## Section title with actions on the right

The usual head of a list or a table: the title column is `-expand`, so it takes the
remaining width and pushes the actions to the right edge. Add one column per action.

```html
<div class="araxxe-horizontal-spacing -s10 -middle">
  <div class="araxxe-horizontal-spacing--column -expand">
    <h2 class="araxxe-title-big">42 calls</h2>
  </div>
  <div class="araxxe-horizontal-spacing--column">
    <button class="araxxe-button-rounded -ghost">
      <span class="araxxe-button-rounded--slot">
        <span class="araxxe-icon araxxe-glyph-cloud-dl -s24"></span>
      </span>
      <span class="araxxe-button-rounded--slot">Export</span>
    </button>
  </div>
</div>
```

## Muted or emphasised text

Body text is `araxxe-paragraph` (block) or `araxxe-text` (inline), in the root text style.
`-color-shade-50` mutes it, `-bold` emphasises it. `araxxe-description` is not body text:
it is a larger semi-bold lead in the secondary font.

```html
<p class="araxxe-paragraph">
  <span class="araxxe-text -color-shade-50">Team day:</span>
  <span class="araxxe-text -bold">Tuesday</span>
</p>
```

## Grid of cards of equal height

`-equivalent` gives every column the same width; `-vertical-expand` makes each card fill
the height of its row. One `araxxe-horizontal-spacing` per row.

```html
<div class="araxxe-horizontal-spacing -s30 -equivalent">
  <div class="araxxe-horizontal-spacing--column">
    <div class="araxxe-card -vertical-expand">First card</div>
  </div>
  <div class="araxxe-horizontal-spacing--column">
    <div class="araxxe-card -vertical-expand">Second card</div>
  </div>
</div>
```

## Card title row: title, trailing badge, subtitle

The library has no header element for this layout: the campaign card of
[card.md](/ai/components/card.md) composes it from the spacing components, as below. The
`-expand` column takes the remaining width and pushes the badge to the right. When the
card has content under this row, the card stacks the two with an
`araxxe-vertical-spacing -s20` (one `--line` for this block, one for the content).
`araxxe-card--header` is something else: a colored band with contrasting text, on a
`araxxe-card -wrapped` whose color modifier (`-service-ebv`, `-a2psms-o`…) sets the band
color, followed by an `araxxe-card--body` that restores the padding.

```html
<div class="araxxe-card">
  <div class="araxxe-vertical-spacing -s5">
    <div class="araxxe-vertical-spacing--line">
      <div class="araxxe-horizontal-spacing -s10 -middle">
        <div class="araxxe-horizontal-spacing--column -expand">
          <h3 class="araxxe-title-card">Finance</h3>
        </div>
        <div class="araxxe-horizontal-spacing--column">
          <div class="araxxe-badge -inactive">5 members</div>
        </div>
      </div>
    </div>
    <div class="araxxe-vertical-spacing--line">
      <div class="araxxe-subtitle-card">Accounting and general services</div>
    </div>
  </div>
</div>
```

## Key figures side by side, separated by a rule

`araxxe-horizontal-separe` draws a vertical rule between its columns: put one
`--separator` between two `--column`s (`-equivalent` gives the columns the same width).
Each figure is a [label-legend](/ai/components/label-legend.md): the value (`--label`)
above its caption (`--legend`, cut with an ellipsis when too long). Choose a variant:
`-primary` for headline figures (large value in the primary color), `-secondary` for smaller muted ones.
`araxxe-label-legend` takes no color modifier: for figures colored by a service, copy the
campaign card of [card.md](/ai/components/card.md) instead
(`araxxe-description -color-service-*` above an `araxxe-title-info`).

```html
<div class="araxxe-horizontal-separe">
  <div class="araxxe-horizontal-separe--column">
    <div class="araxxe-label-legend -primary">
      <div class="araxxe-label-legend--label">7</div>
      <div class="araxxe-label-legend--legend">Objectives</div>
    </div>
  </div>
  <div class="araxxe-horizontal-separe--separator"></div>
  <div class="araxxe-horizontal-separe--column">
    <div class="araxxe-label-legend -primary">
      <div class="araxxe-label-legend--label">3</div>
      <div class="araxxe-label-legend--legend">Alerts</div>
    </div>
  </div>
</div>
```

## Labels and their values

`araxxe-table-details` lines up each label (`araxxe-title-info`, in the `th`) in front of
its value (`araxxe-text -bold`, in the `td`): one `--line` per pair, no spacing block. The
details pages put it in an `araxxe-table-layout -light`, a light rounded panel with
padding, in their side column.

```html
<div class="araxxe-table-layout -light">
  <table class="araxxe-table-details">
    <tr class="araxxe-table-details--line">
      <th class="araxxe-table-details--cell"><div class="araxxe-title-info">Team day</div></th>
      <td class="araxxe-table-details--cell"><span class="araxxe-text -bold">Tuesday</span></td>
    </tr>
    <tr class="araxxe-table-details--line">
      <th class="araxxe-table-details--cell"><div class="araxxe-title-info">Members</div></th>
      <td class="araxxe-table-details--cell"><span class="araxxe-text -bold">5</span></td>
    </tr>
  </table>
</div>
```

## List of chips

`araxxe-list-inline` wraps its items; `araxxe-badge -border` is the neutral chip (the
other badge modifiers are colored and carry a meaning). A badge is always uppercase and
bold.

```html
<ul class="araxxe-list-inline">
  <li class="araxxe-list-inline--item"><div class="araxxe-badge -border">Alice Martin</div></li>
  <li class="araxxe-list-inline--item"><div class="araxxe-badge -border">Bob Durand</div></li>
</ul>
```

## Legend of a chart: colored dot, label, value

The `-fill-graph-<n>` colors belong to charts: the dot of a legend row takes the color
of the slice it describes (`araxxe-pie-chart--piece -fill-graph-<n>`, see
[pie-chart.md](/ai/components/pie-chart.md)), row 1 for slice 1 and so on. Do not use
them to tell teams or categories apart outside a chart: the library has no decorative
palette (see "When nothing fits"). For a measure without a dot (a number, its unit and a
caption underneath), use [measure-legend](/ai/components/measure-legend.md).

```html
<table class="araxxe-table-simple -expandable -underlined">
  <tbody class="araxxe-table-simple--tbody">
    <tr class="araxxe-table-simple--line -align-middle">
      <td class="araxxe-table-simple--cell">
        <span class="araxxe-spot -s18 -fill-graph-1"></span>
      </td>
      <td class="araxxe-table-simple--cell -expand">Delivered</td>
      <td class="araxxe-table-simple--cell -align-right"><p class="araxxe-description">1234</p></td>
    </tr>
    <tr class="araxxe-table-simple--line -align-middle">
      <td class="araxxe-table-simple--cell">
        <span class="araxxe-spot -s18 -fill-graph-2"></span>
      </td>
      <td class="araxxe-table-simple--cell -expand">Pending</td>
      <td class="araxxe-table-simple--cell -align-right"><p class="araxxe-description">42</p></td>
    </tr>
  </tbody>
</table>
```

## Form with errors, in a dialog

A form in a dialog goes in a [modal](/ai/components/modal.md): its header holds the title
and the close button, its footer the actions, and the page shows it in the
`araxxe-template-modal` shell of [page-skeleton.md](/ai/page-skeleton.md). Inside
`--content`, the fields are stacked by an `araxxe-vertical-spacing -s10`, one `--line`
per field. The footer centers a `-ghost` cancel button and a plain confirm button. The
`<form>` sits in `--content` and the buttons in `--footer`: the `form` attribute links the
confirm button to it. A filter form next to the page content goes in an
[aside](/ai/components/aside.md) instead (fields in `--content`, a `-block` button in
`--footer`). For a form inside the page, stack the fields the same way: the library shows
no actions row for it.

While a value is invalid, the application adds `ion--field-error` on the field and the
`--message` holding an `araxxe-tooltip-field -error`; it removes both once the value is
valid (see [field.md](/ai/components/field.md)).

```html
<div class="araxxe-modal -w700">
  <div class="araxxe-modal--header">
    <div class="araxxe-modal--header--title">
      <h2 class="araxxe-title-medium">New rule</h2>
    </div>
    <button class="araxxe-modal--header--button araxxe-glyph-close"></button>
  </div>
  <div class="araxxe-modal--content">
    <form id="rule-form">
      <div class="araxxe-vertical-spacing -s10">
        <div class="araxxe-vertical-spacing--line">
          <div class="araxxe-field">
            <label class="araxxe-field--label"><span class="araxxe-text-info">Name</span></label>
            <div class="araxxe-field--group"><input class="araxxe-input-text" type="text" /></div>
          </div>
        </div>
        <div class="araxxe-vertical-spacing--line">
          <div class="araxxe-field ion--field-error">
            <label class="araxxe-field--label"
              ><span class="araxxe-text-info">USSD command</span></label
            >
            <div class="araxxe-field--group">
              <input class="araxxe-input-text" type="text" />
              <div class="araxxe-field--message">
                <span class="araxxe-tooltip-field -error">
                  <span class="araxxe-tooltip-field--icon araxxe-glyph-contact"></span>
                  <span class="araxxe-tooltip-field--text">This field is mandatory</span>
                  <span class="araxxe-tooltip-field--triangle"></span>
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
  <div class="araxxe-modal--footer">
    <div class="araxxe-horizontal-spacing -s20 -middle -center">
      <div class="araxxe-horizontal-spacing--column">
        <button class="araxxe-button -ghost" type="button">Cancel</button>
      </div>
      <div class="araxxe-horizontal-spacing--column">
        <button class="araxxe-button" type="submit" form="rule-form">Confirm</button>
      </div>
    </div>
  </div>
</div>
```

## Loading placeholder that keeps the layout

While data loads, render the final layout with an `araxxe-twinkle-area` in place of each
piece of content, so that nothing moves when the data arrives. Give each placeholder about
the height of what it replaces: `-h44` for an `araxxe-title-big` or a button, `-h34` for
an input or a table header cell, `-h20` for a line of text. Add a width `-w<n>` for short
content (`-w240` for a title); without one, the placeholder fills its column. A table
keeps its markup, with placeholder cells on a few rows:

```html
<table class="araxxe-table-simple">
  <thead class="araxxe-table-simple--thead">
    <tr class="araxxe-table-simple--line">
      <th class="araxxe-table-simple--cell"><div class="araxxe-twinkle-area -h34"></div></th>
      <th class="araxxe-table-simple--cell"><div class="araxxe-twinkle-area -h34"></div></th>
    </tr>
  </thead>
  <tbody class="araxxe-table-simple--tbody">
    <tr class="araxxe-table-simple--line">
      <td class="araxxe-table-simple--cell"><div class="araxxe-twinkle-area -h20"></div></td>
      <td class="araxxe-table-simple--cell"><div class="araxxe-twinkle-area -h20"></div></td>
    </tr>
    <tr class="araxxe-table-simple--line">
      <td class="araxxe-table-simple--cell"><div class="araxxe-twinkle-area -h20"></div></td>
      <td class="araxxe-table-simple--cell"><div class="araxxe-twinkle-area -h20"></div></td>
    </tr>
  </tbody>
</table>
```

## Empty list or loading error

When a list has nothing to show, or its data could not be loaded, keep its place with an
`araxxe-card -faded` holding one centered `araxxe-description` that says what happened.
The same markup serves both cases: only the message changes.

```html
<div class="araxxe-card -faded">
  <p class="araxxe-description -align-center">No call matches these filters.</p>
</div>
```

## Icon in front of a text

Check the components first: a status spot with its label is a
[status](/ai/components/status.md), an icon above its label an
[icon-text](/ai/components/icon-text.md). For any other icon before a text, one
`araxxe-horizontal-spacing -middle` aligns the two, as the date row of a
[card.md](/ai/components/card.md) example does (with `-s30` and an `-s24` icon, next to a
larger date); the text column is `-expand`.

```html
<div class="araxxe-horizontal-spacing -s10 -middle">
  <div class="araxxe-horizontal-spacing--column">
    <span class="araxxe-icon araxxe-glyph-date-range -s16 -color-main"></span>
  </div>
  <div class="araxxe-horizontal-spacing--column -expand">
    <span class="araxxe-text">Booked until Friday</span>
  </div>
</div>
```

## When nothing fits

Say so instead of forcing a component: the library has a fixed content width (wider with `-wide`; values under Layout in
[DESIGN.md](/DESIGN.md)), no free color palette, and only the glyphs of
[icons.md](/ai/icons.md). Report the gap to the user, then use the closest documented
pattern or, as a last resort, custom CSS built on the tokens of [DESIGN.md](/DESIGN.md).
