Skip to content

Playground

Edit an indah app and run it, here, with no install and no server. Your code runs in a Python runtime inside this browser tab and is sent nowhere: there is no server to run it on.

Write a function called build() that returns an indah component (indah is already imported). Press Run to see it; change the code and press Run again.

Tab indents; press Escape, then Tab, to leave the editor. Ctrl+Enter (or Cmd+Enter) runs.

Loads about 9 MB, then runs in your browser. Nothing is sent anywhere.

Starting points

The quickstart app
import indah


def build():
    a, b = indah.Signal(2), indah.Signal(3)
    total = indah.computed(lambda: f"a + b = {a.value + b.value}")
    return indah.Column(
        children=[
            indah.Slider(a, min=0, max=10, label="a"),
            indah.Slider(b, min=0, max=10, label="b"),
            indah.Text(total),
        ]
    )
Row, Grid and Card
import indah


def build():
    def stat(title: str, value: str, *, figure: bool = False) -> indah.Component:
        text = indah.Text(value, variant="readout") if figure else indah.Text(value)
        return indah.Card(title=title, children=[text])

    return indah.Column(
        children=[
            indah.Text("A Row puts cards side by side:"),
            indah.Row(
                children=[stat("Requests", "1.2k", figure=True), stat("Errors", "0", figure=True)]
            ),
            indah.Text("A Grid wraps them into columns:"),
            indah.Grid(
                columns=3,
                gap="0.75rem",
                children=[stat(f"Tile {n}", f"value {n}") for n in range(1, 7)],
            ),
        ]
    )
Counter
import indah


def build():
    n = indah.Signal(0)
    return indah.Column(children=[
        indah.Button("Add one", lambda: n.set(n.value + 1)),
        indah.Text(lambda: f"n = {n.value}"),
    ])
Celsius to Fahrenheit
import indah


def build():
    c = indah.Signal(21.0)
    f = indah.computed(lambda: round(c.value * 9 / 5 + 32, 1))
    return indah.Card(title="Converter", children=[
        indah.Slider(c, min=-20, max=45, step=0.5, label="Celsius"),
        indah.Text(lambda: f"{c.value} C = {f.value} F"),
    ])
Searchable table
import indah


def build():
    rows = [{"n": i, "square": i * i, "even": "yes" if i % 2 == 0 else "no"} for i in range(1, 201)]
    return indah.Table(
        rows=rows, key="n", search=True, height="22rem",
        columns=[indah.Col("n", kind="number"), indah.Col("square", kind="number"),
                 indah.Col("even", kind="badge", tones={"yes": "ok", "no": "neutral"})],
    )
Name tag (two inputs)
import indah


def build():
    first = indah.Signal("Ada")
    last = indah.Signal("Lovelace")
    return indah.Column(children=[
        indah.TextInput(first, label="First name"),
        indah.TextInput(last, label="Last name"),
        indah.Text(lambda: f"## {first.value} {last.value}", markdown=True),
    ])

What to expect

  • Download. Nothing loads when you open this page. The first Run downloads the Python runtime and indah, about 9 MB compressed (once; your browser keeps it).
  • Time. A run takes about 4 seconds to start once the download is cached, and 4 to 6 seconds the first time, because every run starts a fresh Python. That is also what makes Stop reliable: stopping throws the whole runtime away.
  • Endless loops. If your code does not return, the Playground stops it after 5 seconds and says so. Stop does the same at any time. Nothing else on the page is affected, and the runtime restarts on the next run.
  • Errors. A syntax error or an exception in your code is shown under the editor, as a traceback starting at your own lines.
  • Keyboard. Tab indents inside the editor. Press Escape, then Tab, to leave it. Ctrl+Enter (Cmd+Enter on a Mac) runs.
  • No JavaScript. The editor and the starting points are plain text you can read and copy; running needs JavaScript.

What does not work here

The runtime is Python and indah only, with no server behind it. These do not work, or work differently, in the Playground:

  • Anything that needs a server: file uploads and downloads, ctx.tail and Topic (they need the app object), request headers and the client address, sessions, sign-in, secure=True, roles, rate limits and the Content-Security-Policy report.
  • Routing with real URLs (Router, deep links): the page has no URL of its own.
  • Extra packages. Only Python's standard library and indah are available, so import numpy, pandas, matplotlib and PIL fail; there is no pip install.
  • Threads and processes. asyncio handlers, asyncio.sleep, ctx.every and ctx.spawn work; threading and subprocess do not.
  • Network. Your code runs in a browser sandbox, so it can only do what a web page can.
  • indah.launch() and create_app(): the Playground is the app. Write build() only.

To run any of these, use indah on your own machine (Quickstart) or try the Studio with make demo, which keeps a server-side playground for the same build() snippets.

Examples of components to try are on the Components page, where many have their own Run it button.