Skip to main content

reflex-knightlab-timeline

PyPI version CI Python versions License: MIT GitHub

A native Reflex component that wraps Knight Lab TimelineJS so you can build interactive, storytelling timelines in pure Python — no HTML, no iframe, no hand-written JavaScript.

It was built by migrating the certifications timeline from the reflex_resume project (which used an iframe → static timeline.html → fetch(timeline.json)) into a reusable, reactive, version-pinned component.

import reflex as rx
from reflex_knightlab_timeline import timeline, TimelineData, Event, Text, TLDate

DATA = TimelineData(events=[
    Event(start_date=TLDate(2024, 12, 14),
          text=Text("Claude Code in Action", "Anthropic Academy")),
    Event(start_date=TLDate(2023, 11, 22),
          text=Text("Data Scientist with Python", "Datacamp")),
])

def index() -> rx.Component:
    return timeline(data=DATA, height="600px")

app = rx.App()
app.add_page(index)

Why native instead of an iframe?

iframe (before) native component (this package)
Isolated from app state Wired into Reflex state via events (on_change, …)
Tied to static files/routes Reusable, pip install-able
Untyped JSON edited by hand Typed Python builders + validation
Loads TimelineJS from a CDN at runtime npm @knight-lab/timelinejs@3.9.11, reproducible

Requirements

Version
Python ≥ 3.11
Reflex ≥ 0.10.0 (tested with 0.10.0)
TimelineJS (npm) @knight-lab/timelinejs@3.9.11 (pinned)

Upgrading from 0.1.x? Version 0.2.0 drops Python 3.10 and Reflex < 0.10, following Reflex 0.10's own requirements. See CHANGELOG.md.

Install

pip install reflex-knightlab-timeline
# or with uv
uv add reflex-knightlab-timeline
# or, from this repo:
uv pip install -e .

Reflex installs the underlying npm package (@knight-lab/timelinejs@3.9.11) automatically on first run.

Usage

Data: three ways

from reflex_knightlab_timeline import (
    timeline, TimelineData, Event, Slide, Era, TLDate, Text, Media, Background,
    TimelineOptions, load_timeline_data,
)

# 1) Typed builders
data = TimelineData(
    title=Slide(text=Text("My Journey")),
    events=[Event(start_date=TLDate(2024, 12, 14),
                  text=Text("A cert", "Description"),
                  media=Media(url="https://...", credit="Coursera"))],
    eras=[Era(TLDate(2018), TLDate(2024), Text("Career"))],
    scale="human",
)

# 2) A raw dict (the TimelineJS JSON format)
data = {"events": [{"start_date": {"year": "2024"}, "text": {"headline": "A"}}]}

# 3) Load an existing timeline.json (e.g. migrated from reflex_resume)
data = load_timeline_data("assets/timeline.json")

Options (all TimelineJS options supported)

opts = TimelineOptions(
    timenav_position="bottom",   # "top" | "bottom"
    timenav_height=200,
    scale_factor=2,
    initial_zoom=2,
    hash_bookmark=False,
    default_bg_color={"r": 255, "g": 255, "b": 255},
    language="es",
    theme="dark",                # "dark" | "contrast" | custom CSS url
)
timeline(data=data, options=opts, height="700px")

Events → Python

class State(rx.State):
    current: str = ""

    @rx.event
    def on_slide(self, unique_id: str):
        self.current = unique_id

timeline(data=data, on_change=State.on_slide)

Supported events: on_change, on_loaded, on_dataloaded, on_nav_next, on_nav_previous, on_zoom_in, on_zoom_out, on_back_to_start.

TimelineJS needs an explicitly sized container — width defaults to "100%" and height to "600px"; override as needed. Sizing props are applied to an outer wrapper and TimelineJS mounts on an inner node that fills it, because TimelineJS overwrites the className of the node it is mounted on.

A Media block must include a url — TimelineJS fails to render a slide whose media has none, so validate() rejects it.

Demo

uv sync --extra dev
cd timeline_demo
uv run --project .. reflex run

The demo renders (1) a timeline authored in Python, and (2) the 178-certification timeline migrated 1:1 from reflex_resume, with live on_change updating state.

Development & tests (TDD)

This package was built test-first. The data layer is pure Python (no Reflex needed); the component contract tests require Reflex.

uv sync --extra dev
uv run python -m pytest     # 45 tests
uv build                    # sdist + wheel into dist/

Releasing

Releases are published to PyPI by GitHub Actions:

  1. Bump version in pyproject.toml and add a CHANGELOG.md entry on a feature branch; open a PR to main. CI (.github/workflows/ci.yml) runs the test suite on Python 3.11–3.13, builds the package and runs twine check.

  2. Merge the PR into main.

  3. Tag the merge commit on main and push the tag:

    git checkout main && git pull
    git tag -a v0.2.0 -m "v0.2.0"
    git push origin v0.2.0
    
  4. .github/workflows/publish.yml checks that the tag matches the pyproject.toml version, re-runs the tests, builds, publishes to PyPI and creates the GitHub release. It authenticates with PyPI Trusted Publishing (OIDC, workflow publish.yml, environment pypi); no API token is stored.

Project layout

custom_components/reflex_knightlab_timeline/
  models.py     # typed TimelineJS data builders
  options.py    # all TimelineJS presentation options
  timeline.py   # the native rx.Component (ref + useEffect wrapper)
timeline_demo/  # Reflex demo app (parity with reflex_resume)
examples/       # minimal app installing the package from PyPI
tests/          # pytest suite
.github/        # CI and PyPI release workflows
specs/          # Spec-Driven Design artifacts (PRD, Tech, Data, API, Plan, Migration)

See specs/ for the full design, and specs/migration/iframe-to-native.md for how to swap the old iframe in reflex_resume.

Credits

  • TimelineJS3 © Northwestern University Knight Lab (MPL/own license — see their repo).
  • Built on Reflex.

License

MIT — see LICENSE.

Metadata

Release files for reflex-knightlab-timeline 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reflex-knightlab-timeline 0.2.0
File Size Uploaded Provenance
reflex_knightlab_timeline-0.2.0.tar.gz 18.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for reflex-knightlab-timeline 0.2.0
File Interpreter ABI Platform
reflex_knightlab_timeline-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.8 kB

Release files / reflex_knightlab_timeline-0.2.0.tar.gz

Download URL reflex_knightlab_timeline-0.2.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
809d2dfea2b8088ee71a22bc838e2395ec069522f77bed0203ab3d98a87af647
BLAKE2b-256 checksum
How to use checksums
5865033622ffc1a0c446e1cf8ac7ea62941cc555be1c6ad91463156c58c30724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / reflex_knightlab_timeline-0.2.0-py3-none-any.whl

Download URL reflex_knightlab_timeline-0.2.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
004b0e00d4d4fad0287638beb0142f07f3577f0888940ebd24f856394dd8f993
BLAKE2b-256 checksum
How to use checksums
24fabeb08089bab21566f2d7bde9cd9866899466aef0283722633483548a3312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for reflex-knightlab-timeline 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for reflex_knightlab_timeline-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page