Eunomia v1.0.0-beta.2
AllAngularReactNext.jsJavaScriptVue
EunomiaSalmonForestVioletOceanGoldFireCustom…
🇬🇧 English🇫🇷 Français

Divider

Divider is a thin line that separates two areas of content, horizontal or vertical.

Overview API Examples Accessibility
Section one
Section two

When to use

Reach for a divider to mark a structural break between two blocks of content, such as sections in a page, items in a list, or entries in a toolbar, where spacing alone isn't a clear enough boundary. It carries no content of its own. For a labeled break (e.g. "OR" between two form sections), place text next to it in your own markup rather than expecting a divider to render one.

Install & usage

Pick a framework in the toolbar above and these snippets adapt.

npm install @eunomia/elements
import "@eunomia/elements/divider.js";
<div>Section one</div>
<eun-divider></eun-divider>
<div>Section two</div>

Importing the file registers <eun-divider> as a custom element, with no further setup needed. It works with any framework, or none, since it's a standard web component.

Guidance

  • Use orientation="vertical" inside a flex or grid parent: it relies on align-self: stretch to span the available height (see "Vertical" in the Examples tab)
  • Override --divider-spacing per instance when the surrounding layout already has its own gap, rather than stacking the divider's default margin on top of it
  • Leave --divider-color untouched in most cases: it already tracks the shared --eun-border-color token, so it stays consistent with borders elsewhere on the page
  • Reaching for a divider where spacing alone already reads as a clear break: an extra line can add visual noise rather than clarity
  • Using orientation="vertical" outside a flex/grid parent, or without giving it an explicit height some other way: with nothing to stretch against, it collapses to zero height and renders invisibly
  • Expecting a labeled divider (e.g. "OR") out of the box: slot your own label next to it, since it has no content of its own

Live testing

Properties

Divider <eun-divider>

Attributes

NameTypeDefaultDescription
orientationEunomiaDividerOrientation'horizontal'The direction the line runs along

Import the exact TypeScript type behind any property above, see Types.

CSS custom properties

NameDescription
--divider-colorSets the color of the line, defaulting to the shared border color token
--divider-spacingSets the margin on either side of the line, along its perpendicular axis

Horizontal

The default orientation. Spans the full width of its parent, with margin above/below controlled by --divider-spacing.

Section one
Section two
<div>Section one</div>
<eun-divider></eun-divider>
<div>Section two</div>

Vertical

orientation="vertical" spans the available height of its flex/grid parent, via align-self: stretch, with margin left/right controlled by --divider-spacing.

Left
Right
<div style="display: flex; align-items: stretch;">
  <div>Left</div>
  <eun-divider orientation="vertical"></eun-divider>
  <div>Right</div>
</div>

Custom color

--divider-color overrides the line color, falling back to the shared --eun-border-color token when unset.

Section one
Section two
<eun-divider style="--divider-color: #1a73e8;"></eun-divider>

Custom spacing

--divider-spacing overrides the margin on either side of the line (margin-block when horizontal, margin-inline when vertical), defaulting to --eun-space-m (16px).

Section one
Section two
<eun-divider style="--divider-spacing: 4px;"></eun-divider>

Role and orientation

eun-divider sets role="separator" on itself once connected, unless the consumer already supplied a role attribute, in which case that value is left untouched. aria-orientation is kept in sync with the orientation property ("horizontal" or "vertical"), matching the ARIA separator role.

Non-focusable

eun-divider isn't a focusable element and doesn't appear in the tab order: it's a structural marker, not an interactive control.

Reference links

MDN: ARIA separator role