Quickstart
Get Trellis installed and running in a few minutes.
Installation
Install Trellis from Git:
pip install git+https://github.com/emmapowers/trellis.git
Run the Demo
Trellis includes a demo app. Run it to make sure everything works:
python -m trellis.examples.demo
Open http://127.0.0.1:8000 in your browser. You should see an interactive counter.
To run as a desktop app:
python -m trellis.examples.demo --desktop
Your First App
Create two files:
trellis_config.py:
from trellis.app.config import Config
config = Config(name="My App", module="app")
app.py:
from trellis import App, component, state_var
from trellis import widgets as w
@component
def MyApp() -> None:
count = state_var(0)
def increment() -> None:
nonlocal count
count += 1
with w.Column():
w.Heading(text="My First Trellis App")
w.Label(text=f"Count: {count}")
w.Button(text="Increment", on_click=increment)
app = App(MyApp)
Run it:
trellis run
Open http://127.0.0.1:8000. Click the button—the count updates.
Or run as a desktop app:
trellis run --desktop
The first desktop run may download a matching runtime wheel. If no compatible
published wheel exists for your Python/platform, install pytauri-wheel
manually in that environment.
What Just Happened?
-
state_var()— You created a small slot-local piece of reactive state. When its value changes, readers re-render automatically. -
@component— You defined a component function. It describes what the UI should look like. The decorator applies an AST transform so you can read and writecountdirectly — no.valueneeded. Thenonlocaldeclaration is not strictly required after the transform (since the transform rewrites assignments to.valueaccess), but is recommended to satisfy linters like ruff and type checkers. -
with w.Column():— Components nest using Python'swithblocks.Columnarranges children vertically. -
w.Heading(),w.Label()— Widgets for displaying text.Headingrenders semantic HTML headings. -
w.Button(..., on_click=...)— A widget with an event handler. When clicked, it updatescount. -
Automatic updates — When
countchanges, components that read it re-render automatically.
Next Steps
- Concepts — Understand components, state, and reactivity
- Building UIs — HTML elements, widgets, and styling