Docs
Timeline
Timeline
Timeline displays a list of events in chronological order.
- EatBecause you need strength
- CodeBecause it's awesome!
- SleepBecause you need rest
- RepeatBecause this is the life you love!
Installation
pnpm dlx cross-env REGISTRY_URL=https://ui-x.junwen-k.dev/r pnpm dlx shadcn@latest add 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!
Alternate
- EatBecause you need strength
- CodeBecause it's awesome!
- SleepBecause you need rest
- RepeatBecause this is the life you love!
With Icon
- EatBecause you need strength
- CodeBecause it's awesome!
- SleepBecause you need rest
- RepeatBecause this is the life you love!
Horizontal
- Ordered9.15 AM, January 1, 2024
- Shipped12:20 PM, January 4, 2024
- Out for Delivery07:00 AM, January 8, 2024
Changelog
10 Febuary 2025 - a11y for title and description
- Changed the
TimelineTitle
andTimelineDescription
components to usediv
instead ofh3
andp
to improve accessibility.
timeline.tsx
export const TimelineTitle = React.forwardRef<
React.ElementRef<"div">,
React.ComponentPropsWithoutRef<"div">
>((props, ref) => {
const { orientation } = useTimeline()
return <div ref={ref} data-orientation={orientation} {...props} />
})
TimelineTitle.displayName = "TimelineTitle"
export const TimelineDescription = React.forwardRef<
React.ElementRef<"div">,
React.ComponentPropsWithoutRef<"div">
>(({ className, ...props }, ref) => {
const { orientation } = useTimeline()
return (
<div
ref={ref}
data-orientation={orientation}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
)
})
TimelineDescription.displayName = "TimelineDescription"