Skip to main content

Catalog · Page structure

Tool

The page of a tool in two parts: the settings and what they make, side by side when both fit and one above the other on a phone.

Fits best: app, landing — a page that is a tool, such as a generator, a converter or a calculator, and the hero of a landing page that is one

Example

A generator of sample rows: the settings on one side, the rows they make on the other. Narrow the window and the result moves below the settings.

Settings

Result

3 rows for Spain

NameCityPostcode
Lucía GómezCádiz11001
Pablo RuizVejer11150
Marta SanzTarifa11380

Known issues

None known.

Code

Copy the markup

Bundler
import "@luz-ds/catalog/components/tool.css";
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@luz-ds/catalog@0.5.1/dist/components/tool.min.css" integrity="sha384-zks1Bw5RJt/lne0Gjp3ZZpV8oAIV1pFJwR3r+D73Quj1KarpfquiHXEUTjE6kK8n" crossorigin="anonymous">

The settings are a <form> and come first; the result is a <section> with its actions on top. Two short fields share a row, and the options rarely changed are folded:

HTML
<div class="luz-tool">
  <form class="luz-tool__settings o-stack" aria-labelledby="settings-title">
    <h2 id="settings-title">Settings</h2>
    <div class="o-grid o-grid--split">
      <div class="luz-field">
        <label class="luz-field__label" for="country">Country</label>
        <select class="luz-select" id="country">…</select>
      </div>
      <div class="luz-field">
        <label class="luz-field__label" for="rows">Rows</label>
        <input class="luz-input" id="rows" type="number" value="20" min="1" max="1000">
      </div>
    </div>
    <details>
      <summary>More options</summary>
      <fieldset class="luz-fieldset">…</fieldset>
    </details>
  </form>
  <section class="luz-tool__result o-stack" aria-labelledby="result-title">
    <div class="o-row">
      <h2 id="result-title">Result</h2>
      <button class="luz-btn luz-btn--primary" type="button">Download CSV</button>
      <button class="luz-btn luz-btn--ghost" type="button">Copy</button>
    </div>
    <p role="status">20 rows for Spain</p>
    <div class="luz-table-wrap" role="region" aria-label="Rows made" tabindex="0">
      <table class="luz-table">…</table>
    </div>
  </section>
</div>

Variants and options

No modifier. A block and its two parts.

ClassWhat it does
.luz-tool
The block: a row that wraps, xl between the columns and lg between the rows
.luz-tool__settings
The settings, first: about 18rem wide while the result is beside them, the whole width below
.luz-tool__result
What the settings make: it takes what is left of the row, and goes below the settings when it would be narrower than half of it

How it works

CSS from components/tool.css of @luz-ds/catalog: a flexible row that wraps, with no media query. No JavaScript.

  • The two parts sit side by side while the result keeps half the row beside 18rem of settings, from about 640px of room. Below that, the result wraps under the settings, in the order of the markup.
  • It answers to the room it has, not to the window: inside an app with a sidebar, or with larger text, it stacks sooner.
  • A wide table never widens the result: it scrolls inside its .luz-table-wrap.
  • What fills the result and answers the settings is your script; the pattern only places the two parts.

Without JavaScript

The layout does not change: it is CSS. A tool that computes in the browser says in a <noscript> that it needs its script, and keeps its heading, its text and its form readable.

Keyboard and ARIA

  • Order: the order of the source, which the layout does not change: the settings, then the result and its actions.
  • Landmarks: name the form and the section by their headings with aria-labelledby, and give the table wrapper a name of its own, so no two regions share one.
  • Answers: a role="status" line in the result says what was made, so a screen reader hears the answer to a change of the settings.

Contrast and focus are in the Design tab.

Design

When to use

Use it for a page that is a tool: the visitor sets a few things and takes a result away, again and again.

  • A generator, a converter, a calculator or a formatter.
  • The hero of a landing page whose product is used in the page.

When not to use

Do not use it for a form that is sent and answered later, such as a sign-up: that is one column.

  • A view of figures and data takes the dashboard.
  • A navigation beside the content is the sidebar, not the settings column.

Do and don't

Do Keep the settings short and the result beside them, with its one primary action on top.
<div class="luz-tool">
  <form class="luz-tool__settings">…two fields, more in a details…</form>
  <section class="luz-tool__result">…Download, then the table…</section>
</div>
Don't Put the result first in the markup to show it on the left: a keyboard and a screen reader then meet it before the settings that make it.
<div class="luz-tool">
  <section class="luz-tool__result">…</section>
  <form class="luz-tool__settings">…</form>
</div>

Writing the content

The two headings say what each part is: "Settings" and "Result", or the name of what is made ("Rows").

  • Labels of one to three words; an explanation goes in the help text of the field.
  • The primary button says its verb and what it makes: "Download CSV".
  • The status line says what was made, with its count: "20 rows for Spain".

Contrast and focus

The tool sets no colour of its own. Its text sits on the page surface, and the fields and buttons keep their own colours.

PartColour on backgroundLightDarkHigh contrastNeeds
Text
--luz-text-primary on --luz-surface-page
15.8:1
15.1:1
21.0:1
4.5:1
Focus ring
--luz-focus-ring on --luz-surface-page
5.6:1
7.7:1
21.0:1
3:1

Measured from the token values of each mode, rounded down. Needs is the WCAG 2.2 AA minimum: 4.5:1 for text, 3:1 for focus rings, borders and icons.

  • Focus: every field, button and the table wrapper keep core's ring, 2 px of --luz-focus-ring.
  • Reflow: at 320px it is one column and the page does not scroll sideways. It is checked in the tests.

Tokens it uses

The 2 tokens that the .luz-tool rules of catalog’s components/tool.css read, by family. Each family links to its page, with the values in every mode. In Figma they are variables with the same names: see Tokens in Figma.

Spacing and sizing
--luz-space-lg, --luz-space-xl

Keyboard and ARIA are in the Code tab.