Timeline
Vertical ordered list of events, each with a marker on a connecting line, a title and an optional time and description.
pnpm dlx shadcn@latest add @haze/timeline---
import { cn } from "../../../lib/haze/utils";
interface TimelineItem {
title: string;
/** Visible time or date text. You control the format. */
date?: string;
/** Machine-readable date for the <time> element, for example "2026-11-14T11:02". */
datetime?: string;
description?: string;
/** Marks the current or latest entry with a solid marker. When no item sets it, the last item is current. */
current?: boolean;
/** An icon component, for example one from @lucide/astro. Swaps the dot for an icon chip. Decorative. */
icon?: (props: Record<string, unknown>) => unknown;
}
interface Props {
items: TimelineItem[];
class?: string;
}
const { items, class: className } = Astro.props;
const hasCurrent = items.some((item) => item.current);
const lineDot = "absolute top-4 -bottom-1 left-1/2 w-px -translate-x-1/2 bg-border-strong forced-colors:bg-[CanvasText]";
const lineChip = "absolute top-8 -bottom-1 left-1/2 w-px -translate-x-1/2 bg-border-strong forced-colors:bg-[CanvasText]";
---
<ol role="list" class={cn("m-0 list-none p-0", className)}>
{
items.map((item, index) => {
const last = index === items.length - 1;
const current = hasCurrent ? Boolean(item.current) : last;
const Icon = item.icon;
return (
<li class="relative flex gap-2">
<div class="relative flex w-7 shrink-0 justify-center">
{!last && <span class={Icon ? lineChip : lineDot} aria-hidden="true" />}
{Icon ? (
<span
class="relative z-10 flex size-7 items-center justify-center rounded-full border border-frame bg-field text-muted-foreground forced-colors:border-current"
aria-hidden="true"
>
<Icon class="size-3.5" aria-hidden="true" />
</span>
) : (
<span
class={cn("relative z-10 mt-[5px] size-2.5 rounded-full ring-4 ring-background forced-colors:border forced-colors:border-current", current ? "bg-foreground forced-colors:border-4" : "bg-border-strong")}
aria-hidden="true"
/>
)}
</div>
<div class={cn("grid min-w-0 flex-1 gap-1", Icon && "pt-1", !last && "pb-6")}>
<div class="flex flex-wrap items-baseline justify-between gap-x-3">
<p class="text-[0.8125rem]/5 font-medium text-foreground">{item.title}</p>
{item.date &&
(item.datetime ? (
<time datetime={item.datetime} class="text-[0.8125rem]/5 text-muted-foreground tabular-nums">
{item.date}
</time>
) : (
<p class="text-[0.8125rem]/5 text-muted-foreground tabular-nums">{item.date}</p>
))}
</div>
{item.description && <p class="text-[0.8125rem]/5 text-muted-foreground">{item.description}</p>}
</div>
</li>
);
})
}
</ol>When to use
- An order, shipment or incident history where the sequence matters
- An activity feed in a settings or detail page
- A short release or project history with a date per entry
When not to use
- Steps the user has to complete in order; stepper shows progress and the current step
- Long feeds that need paging; render a table or paginate the list
Installation
Add the Haze registry to components.json once, then install Timeline with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/timelinenpx shadcn@latest add @haze/timelineyarn dlx shadcn@latest add @haze/timelinebunx --bun shadcn@latest add @haze/timelineFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| items* | { title: string; date?: string; datetime?: string; description?: string; current?: boolean; icon?: Icon }[] | – | Events in display order. date is the visible text, so you control the format. datetime is the machine-readable value and turns the date into a <time> element. current marks the latest entry (the last item when none is marked). icon is a lucide component that replaces the dot with a chip. |
| class | string | – | Extra classes on the <ol>. |
Accessibility
- The latest entry has a solid marker; an entry can carry an icon chip instead of a dot.
- An ordered list, so a screen reader announces "list, 4 items" and the position of each event.
- The markers, icon chips and the connecting line are aria-hidden; order is carried by the list itself, not by the drawing. The current entry is marked only visually, so say so in its title or description if it matters.
- Pass datetime to render the date as a <time> element; otherwise it is a plain paragraph. Write the visible date so it reads well aloud, for example "14 Nov 2026, 11:02".
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Timeline" with `npx shadcn@latest add @haze/timeline`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Timeline from "@/components/haze/ui/timeline.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/timeline.md
Customize with real content
Adapt the Haze timeline ui for our product. Replace the demo values of these props with our real content: items, class. Keep the layout, the heading level rules and these accessibility details: The latest entry has a solid marker; an entry can carry an icon chip instead of a dot. An ordered list, so a screen reader announces "list, 4 items" and the position of each event. The markers, icon chips and the connecting line are aria-hidden; order is carried by the list itself, not by the drawing. The current entry is marked only visually, so say so in its title or description if it matters. Pass datetime to render the date as a <time> element; otherwise it is a plain paragraph. Write the visible date so it reads well aloud, for example "14 Nov 2026, 11:02". Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using timeline, check it fits: use it when an order, shipment or incident history where the sequence matters; an activity feed in a settings or detail page; a short release or project history with a date per entry. Avoid it when steps the user has to complete in order; stepper shows progress and the current step; long feeds that need paging; render a table or paginate the list. Alternatives: @haze/stepper, @haze/table, @haze/item.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.