Leaders

Rows of a name and a value joined by a dotted line, for menus, price lists, hours and contents pages.

Example

View Code
<dl class="leaders">
    <div><dt>Soup of the day</dt><dd>$9</dd></div>
    <div><dt>Roast chicken with lemon, thyme and charred greens</dt><dd>$24</dd></div>
    <div><dt>Trout with brown butter</dt><dd>$21</dd></div>
</dl>

When to use it

A name and a value a reader's eye has to travel between: a menu, a price list, opening hours, the page numbers on a contents page. The dotted line carries the eye across. If the rows have more than two things to compare, use a table.

How it works

Each child of leaders is a row. Its first child is the name and its second is the value, and the line fills the space between them. The line is the row's own ::after, so there is no element to add and the markup stays valid: a dl can hold nothing between a dt and its dd.

<dl class="leaders">
    <div><dt>Soup of the day</dt><dd>$9</dd></div>
    <div><dt>Roast chicken with lemon and thyme</dt><dd>$24</dd></div>
</dl>

The rows can be any elements, so a contents page is a list. role="list" takes the list's markers off:

View Code
<ol class="leaders" role="list">
    <li><a href="#">Starters</a><span>12</span></li>
    <li><a href="#">Mains</a><span>18</span></li>
</ol>

A row with no value draws no line. The second child is always the value, so a row with a description but no price keeps an empty element in that place, with nothing inside it, not even a space: <h3>Market fish</h3><strong></strong><p>Ask what came in today.</p>. A long name wraps, and the line and the value stay on its last line. The line never gets shorter than 1.5rem, so a name that would fill the row wraps sooner to leave room for it.

Anything after the value sits below the row at the full width, which is where a dish's description goes:

View Code
<div class="leaders" data-gap="md">
    <article>
        <h3>Trout</h3>
        <strong>$21</strong>
        <p>With brown butter and almonds.</p>
    </article>
</div>

A row can stand alone. data-row makes the element the row itself, for a name and a price among other content, with no wrapper around it:

<article class="stack">
    <figure>…</figure>
    <div class="leaders" data-row><h3>Trout</h3><strong>$21</strong></div>
</article>

data-gap is the space between rows. --yeti-leaders-line is the line itself, written as a border: 2px dotted in the muted text color by default. The dots stand on the baseline, as printed dots do. To raise them, move the line in your theme with .leaders > *::after { translate: 0 -0.3em; }.

Why this name

Leaders are what typesetters call the line of dots that leads the eye across a page. Foundation 6 had nothing for it.

Attributes

Attribute Type Values Default Description
data-gap enum none, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, xs-sm, xs-md, xs-lg, xs-xl, xs-2xl, xs-3xl, xs-4xl, sm-md, sm-lg, sm-xl, sm-2xl, sm-3xl, sm-4xl, md-lg, md-xl, md-2xl, md-3xl, md-4xl, lg-xl, lg-2xl, lg-3xl, lg-4xl, xl-2xl, xl-3xl, xl-4xl, 2xl-3xl, 2xl-4xl, 3xl-4xl sm Space between rows.
data-row boolean This element is a single row: its first child is the name and its second the value, with no wrapper.

Children

  • > *: at least 1. A row, unless data-row makes the element one. Its first child is the name and its second the value, left empty for a row with none; anything after them sits below at the full width.

Tokens

Token Description
--yeti-leaders-line The line between the name and the value, written as a border.
--yeti-space-sm The default gap between rows.
--yeti-space-xs The space either side of the line.
Internal tokens (may change between minor versions) - `--_yeti-gap`

Accessibility

  • The line is decoration and is not read out. Use a dl when the rows are terms and values, and a list when they are links.

Browser support

  • Used without guards: CSS grid, last baseline alignment, fit-content()
  • Behind @supports: nothing

JavaScript

None. This component is CSS only.

Available since 7.0.0.