- EatBecause you need strength
- CodeBecause it's awesome!
- SleepBecause you need rest
- RepeatBecause this is the life you love!
import {
Timeline,
TimelineConnector,Installation#
pnpm dlx shadcn@latest add junwen-k/ui-x/timeline
Usage#
import {
Timeline,
TimelineConnector,
TimelineContent,
TimelineDescription,
TimelineDot,
TimelineItem,
TimelineSeparator,
TimelineTitle,
} from "@/components/ui/timeline";<Timeline>
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
<TimelineConnector />
</TimelineSeparator>
<TimelineContent>
<TimelineTitle>Eat</TimelineTitle>
<TimelineDescription>Because you need strength</TimelineDescription>
</TimelineContent>
</TimelineItem>
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
<TimelineConnector />
</TimelineSeparator>
<TimelineContent>
<TimelineTitle>Code</TimelineTitle>
<TimelineDescription>Because it's awesome!</TimelineDescription>
</TimelineContent>
</TimelineItem>
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
<TimelineConnector />
</TimelineSeparator>
<TimelineContent>
<TimelineTitle>Sleep</TimelineTitle>
<TimelineDescription>Because you need rest</TimelineDescription>
</TimelineContent>
</TimelineItem>
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
</TimelineSeparator>
<TimelineContent>
<TimelineTitle>Repeat</TimelineTitle>
<TimelineDescription>
Because this is the life you love!
</TimelineDescription>
</TimelineContent>
</TimelineItem>
</Timeline>Examples#
Default#
- EatBecause you need strength
- CodeBecause it's awesome!
- SleepBecause you need rest
- RepeatBecause this is the life you love!
import {
Timeline,
TimelineConnector,Alternate#
- EatBecause you need strength
- CodeBecause it's awesome!
- SleepBecause you need rest
- RepeatBecause this is the life you love!
import {
Timeline,
TimelineConnector,With Icon#
- EatBecause you need strength
- CodeBecause it's awesome!
- SleepBecause you need rest
- RepeatBecause this is the life you love!
import { Code, Heart, Moon, Pizza } from "lucide-react";
import {Horizontal#
- Ordered9.15 AM, January 1, 2024
- Shipped12:20 PM, January 4, 2024
- Out for Delivery07:00 AM, January 8, 2024
import { PackageCheck, ShoppingCart, Truck } from "lucide-react";
import {Accessibility#
The timeline renders an ordered list (<ol role="list">), so assistive technology announces the number of events and their order. Dots and connectors are purely visual — keep the meaning of each event in its TimelineTitle and TimelineDescription text rather than in the dot's color or icon alone.
API Reference#
Timeline#
The list container. Renders an <ol>.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "horizontal" | "vertical" | "vertical" | The layout direction of the timeline. |
...props | React.ComponentProps<"ol"> | - | Props spread to the list element. |
TimelineItem#
A single event. Renders an <li>.
| Prop | Type | Default | Description |
|---|---|---|---|
render | ReactElement | function | - | Render as a different element. |
...props | React.ComponentProps<"li"> | - | Props spread to the item element. |
TimelineSeparator#
Lays out the dot and connector alongside the content. Renders a <div>.
| Prop | Type | Default | Description |
|---|---|---|---|
render | ReactElement | function | - | Render as a different element. |
...props | React.ComponentProps<"div"> | - | Props spread to the separator element. |
TimelineDot#
The event marker. Renders a <div> showing a dot while empty; place an icon inside to replace it.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "default" | Filled or outlined dot when rendered empty. |
render | ReactElement | function | - | Render as a different element. |
...props | React.ComponentProps<"div"> | - | Props spread to the dot element. |
TimelineConnector#
The line connecting one event to the next. Renders a <div>; omit it on the last item.
| Prop | Type | Default | Description |
|---|---|---|---|
render | ReactElement | function | - | Render as a different element. |
...props | React.ComponentProps<"div"> | - | Props spread to the connector element. |
TimelineContent, TimelineTitle, TimelineDescription#
The event's content, heading text and supporting text. Each renders a <div> and supports the render prop.
useTimeline#
Hook exposing the timeline context (orientation) for building custom parts. Must be used within <Timeline />.