Timeline
A vertical list of what happened, joined by a line: each ui.TimelineItem has a title, an optional time, description and icon in its dot. on_press makes the entries clickable.
ui.timeline · Category: Data · Full reference →


pz.container(ui.timeline([ ui.TimelineItem("Order placed", "We got your order.", time="09:12", icon="shopping-cart"), ui.TimelineItem("Shipped", "On its way with the courier.", time="14:30", icon="truck"), ui.TimelineItem("Delivered", time="Tomorrow", icon="package-check", tint="success"),]), width=360)When to use
Section titled “When to use”- For the history of an order, a ticket or a file, or a changelog.
- For the steps still to come, use a Stepper.
import pyzed as pzfrom pyzed import ui
pz.container(ui.timeline([ ui.TimelineItem("Order placed", "We got your order.", time="09:12", icon="shopping-cart"), ui.TimelineItem("Shipped", "On its way with the courier.", time="14:30", icon="truck"), ui.TimelineItem("Delivered", time="Tomorrow", icon="package-check", tint="success"),]), width=360)Variants
Section titled “Variants”Options
Section titled “Options”

Code
pz.container(ui.timeline(["Created", "Reviewed", "Merged"]), width=300)

icon=, time=Code
pz.container(ui.timeline([ui.TimelineItem("Commit pushed", time="2 min ago", icon="git-commit-horizontal"), ui.TimelineItem("Checks passed", time="1 min ago", icon="check", tint="success")]), width=340)

dense=TrueCode
pz.container(ui.timeline([ui.TimelineItem("Started", time="10:00"), ui.TimelineItem("Paused", time="10:20", tint="warning"), ui.TimelineItem("Finished", time="11:05", tint="success")], dense=True), width=300)

content=Code
pz.container(ui.timeline([ui.TimelineItem("Ada commented", "Looks good to me!", time="Today", icon="message-circle", content=ui.facepile(["Ada", "Grace"]))]), width=340)Events
Section titled “Events”Timeline has 1 event of its own, listed below. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.
| Event | Handler gets | When |
|---|---|---|
on_press |
(index) |
Called with the index of a clicked entry. |
Handler gets is what Pyzed passes to your callable: () means nothing. Any handler can also be a message (a value that is not callable), which goes to update().
Handling the events
Section titled “Handling the events”The same events written three ways. Imperative: methods of the app change self. Declarative: the handlers produce messages and one update() decides. Functional: a pure function draws an immutable state and asks for changes with set_state(...). See Imperative, declarative and functional.
class Orders(pz.App): def __init__(self): self.opened = None
def open(self, index): # on_press: the index of the clicked entry self.opened = index
def view(self): return ui.timeline([ ui.TimelineItem("Order placed", time="09:12", icon="shopping-cart"), ui.TimelineItem("Shipped", "On its way.", time="14:30", icon="truck", tint="success" if self.opened == 1 else "accent"), ], on_press=self.open)from dataclasses import dataclass
@dataclassclass Open: index: int
class Orders(pz.App): opened = None
def update(self, message): match message: case Open(index): self.opened = index
def view(self): return ui.timeline(["Order placed", "Shipped", "Delivered"], on_press=Open)from dataclasses import dataclass
@dataclass(frozen=True)class State: opened: int = -1
def view(state, set_state): return ui.timeline(["Order placed", "Shipped", "Delivered"], on_press=lambda index: set_state(opened=index))Properties and API
Section titled “Properties and API”ui.timeline
Section titled “ui.timeline”timeline(items, *, on_press=None, dense=False, theme=None)Events in order down a line: a history, a changelog, the steps of a delivery. Each entry gets a dot joined to the next one.
| Property | Default | Description |
|---|---|---|
items |
required | ui.TimelineItem objects, dicts with the same keys or plain titles. |
dense |
False |
Small dots and less space. |
theme |
None |
Theme to use instead of the current one (pyzed.theme.current()). |
Events: on_press (events).
ui.TimelineItem
Section titled “ui.TimelineItem”@dataclassclass TimelineItem(title, description=None, time=None, icon=None, tint='accent', content=None)One entry of ui.timeline.
| Property | Default | Description |
|---|---|---|
title |
required | Title. |
description |
None |
Muted text under the title. |
time |
None |
Text at the right of the title (a date, an hour). |
icon |
None |
Icon inside the dot. |
tint |
"accent" |
Color of the dot. |
content |
None |
Any widget under the text. |