import "capsomer/tokens.css";
import "capsomer/timeline.css";
import { Timeline } from "capsomer/react/timeline";
Usage
<ol class="cap-timeline" data-cap="timeline">
<li class="cap-timeline-step">
<span class="cap-timeline-node" aria-hidden="true">01</span>
<div class="cap-timeline-body">
<span class="cap-timeline-icon" aria-hidden="true"><svg>...</svg></span> <!-- optional -->
<h3 class="cap-timeline-title">Send the draft</h3>
<div class="cap-timeline-text"><p>Upload the document and pick a turnaround.</p></div>
</div>
</li>
</ol>
Examples
A site's own look: larger nodes and a gradient fill
<ol class="cap-timeline timeline-specimen-site" data-cap="timeline">
<li class="cap-timeline-step">
<span class="cap-timeline-node" aria-hidden="true">01</span>
<div class="cap-timeline-body">
<h3 class="cap-timeline-title">Field notes</h3>
<div class="cap-timeline-text"><p>Gather what the team saw.</p></div>
</div>
</li>
<li class="cap-timeline-step">
<span class="cap-timeline-node" aria-hidden="true">02</span>
<div class="cap-timeline-body">
<h3 class="cap-timeline-title">Annual report</h3>
<div class="cap-timeline-text"><p>Write it up once a year.</p></div>
</div>
</li>
</ol>
API reference
Timeline
Prop
Type
Required
Does
steps
TimelineStep[]
Yes
level
"h2" | "h3" | "h4"
The steps' heading level on the page.
className
string
Functions
Function
Signature
Does
attach
(el: HTMLElement): () => void
The timeline's behavior: the line between the steps fills from the first to the last once the timeline scrolls into view (200px early). With no script, and with reduced motion, it is drawn full. The fill is a transform, so nothing is measured and a resize needs no work. One timeline: fills its line once it nears the view. Returns a function that undoes it.
enhance
(root?: ParentNode): () => void
CSS variables
Variable
Default
--cap-timeline-duration
calc(var(--dur-slow) * 3)
--cap-timeline-fill
var(--primary)
--cap-timeline-gap
var(--space-7)
--cap-timeline-node
64px
--cap-timeline-node-bg
var(--surface)
--cap-timeline-node-line
var(--line-strong)
--cap-timeline-track
var(--line)
Parts and data attributes
Class
Is
.cap-timeline
the root
.cap-timeline-body
a part
.cap-timeline-icon
a part
.cap-timeline-node
a part
.cap-timeline-step
a part
.cap-timeline-text
a part
.cap-timeline-title
a part
Attribute
Values
data-cap-ready
present or absent
data-shown
present or absent
Accessibility
None: it holds no control (links in a step's words are in the normal order).
ol and li, each step's title a heading at the page's level.
The node numbers and icons are aria-hidden.
In forced colors the line is drawn in system colors.