Divider

A heading or short line with a rule filling the room beside it, for section heads, dates and an "or" between choices.

Example

View Code
<h2 class="divider">Mains</h2>

When to use it

A heading or a short line set between rules: a section head on a menu, a date under a masthead, the "or" between two ways to sign in. For a rule with no text, use hr, or data-rule on a stack for a line between every child.

How it works

The class goes on the element that holds the text, and the rules are that element's own ::before and ::after, so a heading stays a heading and nothing extra is read out. Each rule fills the room left by the text.

<h2 class="divider">Mains</h2>

data-align moves the text. center is the default; start and end put it at that edge with one rule filling the rest.

<h2 class="divider" data-align="start">Mains</h2>

Long text wraps into balanced lines, and the rules give way a little with it. The element's children each take a place in the row, so text with an inline element in it goes in one span:

<p class="divider"><span>Served from <time datetime="12:00">noon</time></span></p>

data-gap is the space either side of the text, and --yeti-divider-line is the rule itself, written as a border: the border width in the border color by default. A divider fills its container, heading or not, so it sets no reading measure.

Why this name

It is what it does, and rule already means the line a stack draws. Foundation 6's hr could not hold text.

Attributes

Attribute Type Values Default Description
data-align enum start, center, end center Where the text sits. start and end leave one rule, filling the rest.
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 md Space either side of the text.

Children

No structural requirements.

Tokens

Token Description
--yeti-divider-line The rule beside the text, written as a border.
--yeti-space-md The default gap.
Internal tokens (may change between minor versions) - `--_yeti-gap`

Accessibility

  • The rules are decoration and are not read out. Keep the heading level the element would have without them.

Browser support

  • Used without guards: flexbox gap, text-wrap: balance
  • Behind @supports: nothing

JavaScript

None. This component is CSS only.

Available since 7.0.0.