Liking cljdoc? Tell your friends :D

x-timeline

A coordinator component that wraps x-timeline-item children. Manages item indexing, last-item tracking, position assignment, and stripe alternation. Works together with x-timeline-item.

Tag name

<x-timeline>
  <x-timeline-item ...></x-timeline-item>
</x-timeline>

Observed attributes

AttributeTypeDefaultDescription
labelstring""Optional caption displayed above the items
positionstring"start"Controls which side item content appears on; see values below
stripedbooleanabsentWhen present, enables alternating stripe backgrounds on items

position values

ValueItem layout
startAll items: content on the right of the track (default)
endAll items: content on the left of the track
alternatingEven-indexed items use start, odd-indexed items use end

JS properties

PropertyTypeDefaultMirrors attribute
labelstring""label
positionstring"start"position
stripedbooleanfalsestriped

Events

x-timeline-select

Fires when the user clicks or activates an x-timeline-item child. The coordinator intercepts x-timeline-item-click (stopping its propagation) and re-dispatches this canonical event.

PropertyValue
bubblestrue
composedtrue
cancelablefalse
detail{ index, status, label } (see below)

Detail shape:

FieldTypeDescription
indexnumber0-based index of the selected item within the timeline
statusstringThe item's status attribute value
labelstringThe item's label attribute value

Slots

SlotDescription
(default)Projects x-timeline-item children

CSS custom properties

PropertyDefaultDescription
--x-timeline-gap0Gap between label and first item
--x-timeline-label-colorinheritLabel text color
--x-timeline-label-font-size0.875remLabel font size
--x-timeline-label-font-weight600Label font weight
--x-timeline-label-padding0 0 0.5remLabel padding

Shadow DOM parts

PartDescription
labelThe caption element above the items

Accessibility

  • The host element always has role="list".
  • aria-label is set from the label attribute when non-empty.
  • Each x-timeline-item child independently carries role="listitem".

Coordinator contract

x-timeline sets the following data-* attributes on each direct x-timeline-item child whenever the item connects, disconnects, or the parent's attributes change:

AttributeValuePurpose
data-index"0", "1", …0-based position in the list
data-lastpresence (boolean)Present on the last item; hides its connector line
data-position"start" | "end"Overrides the item's own position attribute
data-stripedpresence (boolean)Present when striped is set on the parent

Usage examples

Basic

<x-timeline>
  <x-timeline-item status="complete" label="Jan 1" title="Project kick-off"></x-timeline-item>
  <x-timeline-item status="complete" label="Feb 3" title="Design review"></x-timeline-item>
  <x-timeline-item status="active"   label="Mar 15" title="Development"></x-timeline-item>
  <x-timeline-item status="pending"  label="Apr 30" title="Launch"></x-timeline-item>
</x-timeline>

With label

<x-timeline label="Project milestones">
  <x-timeline-item status="complete" title="Phase 1"></x-timeline-item>
  <x-timeline-item status="active"   title="Phase 2"></x-timeline-item>
</x-timeline>

Alternating layout

<x-timeline position="alternating">
  <x-timeline-item status="complete" label="Q1" title="Planning"></x-timeline-item>
  <x-timeline-item status="complete" label="Q2" title="Build"></x-timeline-item>
  <x-timeline-item status="active"   label="Q3" title="Test"></x-timeline-item>
  <x-timeline-item status="pending"  label="Q4" title="Launch"></x-timeline-item>
</x-timeline>

Striped

<x-timeline striped>
  <x-timeline-item status="complete" title="Step 1"></x-timeline-item>
  <x-timeline-item status="active"   title="Step 2"></x-timeline-item>
  <x-timeline-item status="pending"  title="Step 3"></x-timeline-item>
</x-timeline>

Handling selection events

document.querySelector('x-timeline').addEventListener('x-timeline-select', e => {
  const { index, status, label } = e.detail;
  console.log(`Selected item ${index}: ${label} (${status})`);
});

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