Liking cljdoc? Tell your friends :D

x-timeline-item

A single entry in a vertical timeline. Designed to work standalone or inside a future x-timeline parent that coordinates multiple items.

Tag

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

Attributes

AttributeTypeDefaultDescription
labelstring""Date/time or step label shown adjacent to the marker
titlestring""Heading text for this timeline entry
statuspending | active | complete | error | warningpendingControls marker icon and color
iconstring | "none"absentCustom marker icon; "none" hides the icon entirely
connectorsolid | dashed | nonesolidThe vertical line below the marker
positionstart | endstartWhich side the content appears on; overridden by data-position
disabledbooleanabsentMakes the item non-interactive (no click events, pointer-events off)

Parent-managed data attributes

These are set by the future x-timeline parent and are observed for reactive rendering.

AttributeSet byEffect
data-lastx-timelineHides the connector (CSS :host([data-last]) .connector { display:none })
data-indexx-timeline0-based index; used in the marker ARIA label (e.g., "Step 1: …")
data-positionx-timelineOverrides position attr; accepts start or end only
data-stripedx-timelineApplies a subtle stripe background

JS Properties

PropertyTypeMirrors attributeNotes
labelstringlabel
titlestringtitleOverrides native HTMLElement.title (tooltip)
statusstringstatus
iconstring | nullicon
connectorstringconnector
positionstringposition
disabledbooleandisabledBoolean attribute pattern

Events

EventBubblesComposedCancelableDetail
x-timeline-item-connectedyesyesno{ status, label, position, disabled }
x-timeline-item-disconnectednonono{ status, label } — dispatched on document
x-timeline-item-clickyesyesyes{ status, label }

Slots

NameDescription
(default)Main body content
labelOverrides the label attribute
iconCustom marker icon content
actionsAction buttons placed below content

CSS Custom Properties

PropertyDefaultDescription
--x-timeline-item-marker-size2remDiameter of the marker circle
--x-timeline-item-marker-bgper-status (see below)Marker background color
--x-timeline-item-marker-colorper-statusMarker icon/text color
--x-timeline-item-connector-colorper-statusColor of the connector line
--x-timeline-item-connector-width2pxWidth of the connector line
--x-timeline-item-gap0.75remGap between marker and content, and between items
--x-timeline-item-label-width6remWidth of the label column
--x-timeline-item-label-colorrgba(0,0,0,0.5) / dark: rgba(255,255,255,0.5)Label text color
--x-timeline-item-label-font-size0.8125remLabel font size
--x-timeline-item-title-font-size0.9375remTitle font size
--x-timeline-item-stripe-bgrgba(0,0,0,0.025)Background when data-striped is present
--x-timeline-item-motion150msTransition duration for color changes
--x-timeline-item-enter-duration160msDuration of the enter animation

Status color defaults

StatusMarker bg (light)Marker colorConnector color
pendingrgba(0,0,0,0.06)rgba(0,0,0,0.45)rgba(0,0,0,0.12)
activergba(0,102,204,1)#fffrgba(0,102,204,0.4)
completergba(16,140,72,1)#fffrgba(16,140,72,0.5)
errorrgba(190,20,40,1)#fffrgba(190,20,40,0.4)
warningrgba(204,120,0,1)#fffrgba(204,120,0,0.4)

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

Accessibility

  • Host element: role="listitem" — the future x-timeline parent carries role="list"
  • Host aria-label: derived from title (preferred) or label
  • Marker aria-label: "Step N: {label} ({status})" when data-index is set, otherwise "({status})"
  • Default icon span: aria-hidden="true"
  • tabindex="0" when interactive; tabindex="-1" + aria-disabled="true" when disabled
  • pointer-events: none when disabled

Keyboard

KeyConditionAction
Enterfocused, not disabledfires x-timeline-item-click
Spacefocused, not disabledfires x-timeline-item-click

Motion

  • Enter animation: opacity 0→1 + translateX(-4px→0) on connect (reversed for position="end")
  • Color transitions on status change (marker bg/color, connector color)
  • @media (prefers-reduced-motion: reduce) disables all animations and transitions

Usage examples

Basic item

<x-timeline-item
  label="Jan 2024"
  title="Project kickoff"
  status="complete">
  <p>The project was officially started.</p>
</x-timeline-item>

With custom icon

<x-timeline-item status="active" icon="🚀" label="Now">
  <p>In progress.</p>
</x-timeline-item>

With actions slot

<x-timeline-item title="Review" status="pending">
  <p>Awaiting approval.</p>
  <div slot="actions">
    <button>Approve</button>
    <button>Reject</button>
  </div>
</x-timeline-item>

Dashed connector

<x-timeline-item connector="dashed" label="Future">Planned item</x-timeline-item>

Content on the right side

<x-timeline-item position="end" label="Mar 2024" title="Launch">
  Production release.
</x-timeline-item>

Disabled item

<x-timeline-item disabled status="pending" label="TBD">
  Not yet scheduled.
</x-timeline-item>

Listening for events

document.querySelector('x-timeline-item').addEventListener('x-timeline-item-click', e => {
  console.log('Clicked:', e.detail.status, e.detail.label);
});

Parent-child coordination (for future x-timeline)

When building x-timeline, listen for x-timeline-item-connected (bubbling) to detect children, then:

// After each connect, re-index all children
this.addEventListener('x-timeline-item-connected', () => {
  const items = this.querySelectorAll('x-timeline-item');
  items.forEach((item, i) => {
    item.setAttribute('data-index', i);
    if (i === items.length - 1) {
      item.setAttribute('data-last', '');
    } else {
      item.removeAttribute('data-last');
    }
  });
});

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