Liking cljdoc? Tell your friends :D

x-divider

A themeable, accessible divider that separates content sections. Supports horizontal and vertical orientations, solid/dashed/dotted line styles, an optional text label with configurable alignment, and full CSS custom-property theming.


Tag

<x-divider></x-divider>

Attributes

AttributeTypeDefaultDescription
orientationenum"horizontal"Layout axis: horizontal or vertical
variantenum"solid"Line style: solid | dashed | dotted
thicknessstringCSS length for line thickness (e.g. "2px"). Sets --x-divider-thickness
colorstringCSS color for the line. Sets --x-divider-color
insetstringCSS length for inset on both ends. Sets --x-divider-inset
lengthstringCSS size constraining the divider's main axis. Sets --x-divider-length
labelstringText label rendered in the centre of the line
alignenum"center"Label position along the line: center | start | end
rolestring"separator"ARIA role on the host: separator | presentation | none
aria-labelstringAccessible label when role="separator"

Properties

PropertyTypeReflects attribute
orientationstringorientation
variantstringvariant
alignstringalign
labelstringlabel
thicknessstringthickness
colorstringcolor
insetstringinset
lengthstringlength

Slots

SlotDescription
labelAlternative to the label attribute — place inline content inside the label area

Parts

Without label

PartDescription
containerOuter flex wrapper
lineThe single divider line

With label

PartDescription
containerOuter flex wrapper
line-leftLeft/top segment of the line
labelWrapper element around the label content
label-text<span> inside [part=label] holding label text
line-rightRight/bottom segment of the line

CSS Custom Properties

VariableDefaultDescription
--x-divider-colorrgba(0,0,0,0.12) / dark-mode adjustedLine color
--x-divider-thickness1pxLine thickness
--x-divider-inset0pxInset applied to both ends of the line
--x-divider-lengthautoConstrains the main-axis size

Dark-mode defaults are set automatically via @media (prefers-color-scheme: dark).


DOM Behaviour

When no label attribute is set, the shadow DOM is:

div[part=container]
  └── div[part=line]

When a label attribute is present:

div[part=container]
  ├── div[part=line-left]
  ├── span[part=label]
  │     ├── slot[name=label]
  │     └── span[part=label-text]
  └── div[part=line-right]

data-orientation, data-variant, and data-align data attributes are always set on the host element and can be used as CSS hooks.


Accessibility

  • role="separator" (default) marks the element as a thematic separator. Pair with aria-label when context is needed.
  • Set role="presentation" or role="none" for purely decorative dividers so assistive technology ignores them.
  • When orientation="vertical", aria-orientation="vertical" is set on the host.

Examples

Basic horizontal

<x-divider></x-divider>

Vertical in a flex row

<div style="display:flex; height:40px; align-items:stretch">
  <span>Left</span>
  <x-divider orientation="vertical"></x-divider>
  <span>Right</span>
</div>

Dashed with custom colour and thickness

<x-divider variant="dashed" color="#3b82f6" thickness="2px"></x-divider>

Labelled, aligned to start

<x-divider label="Section A" align="start"></x-divider>

Decorative (no ARIA role)

<x-divider role="presentation"></x-divider>

ClojureScript (hiccup)

[:x-divider]

[:x-divider {:orientation "vertical"}]

[:x-divider {:variant "dashed" :color "#3b82f6" :thickness "2px"}]

[:x-divider {:label "Section A" :align "start"}]

[:x-divider {:role "presentation"}]

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close