Demo

Intro Adding Pages Headers & Text Plotly Figures Tables Download Buttons MiniPages (Horizontal Rows) MiniPages: Mixed Content Syntax Highlighted Code Combining Features Export HTML
Produced by staticdash

Intro

StaticDash is a Python library for building beautiful, interactive, static dashboards—no server required. You can combine plots, tables, code, downloads, and more, all with a simple API. This tutorial walks you through every feature with matching code and rendered output.

from staticdash.dashboard import Dashboard, Page
dashboard = Dashboard(title="My Dashboard")

Adding Pages

A dashboard is made up of one or more **pages**. Each page gets a title, a unique slug, and any content you want. To add a page, create a `Page` object and use `dashboard.add_page(page)`.

page = Page("overview", "Overview")
dashboard.add_page(page)

Headers & Text

You can add headers of different levels and paragraphs of text to organize your dashboard.

page.add_header("Header Level 2", level=2)
page.add_header("Header Level 3", level=3)
page.add_header("Header Level 4", level=4)
page.add_text("This is a paragraph of text.")

Header Level 2

Header Level 3

Header Level 4

This is a paragraph of text. Headers help organize your dashboard and provide structure.

Plotly Figures

Add interactive Plotly figures to your dashboard. Just pass a Plotly figure to `add_plot`.

import plotly.express as px
df = px.data.gapminder().query("year == 2007")
fig = px.scatter(df, x="gdpPercap", y="lifeExp", size="pop", color="continent",
                 hover_name="country", log_x=True, size_max=60)
page.add_plot(fig)

Tables

Add pandas DataFrames as sortable, styled tables. Just use `add_table(df)`.

df2 = df[["country", "continent", "lifeExp", "gdpPercap"]]
df2 = df2.sort_values("lifeExp", ascending=False).head(10)
page.add_table(df2)
country continent lifeExp gdpPercap
Japan Asia 82.603 31656.06806
Hong Kong, China Asia 82.208 39724.97867
Iceland Europe 81.757 36180.78919
Switzerland Europe 81.701 37506.41907
Australia Oceania 81.235 34435.36744
Spain Europe 80.941 28821.06370
Sweden Europe 80.884 33859.74835
Israel Asia 80.745 25523.27710
France Europe 80.657 30470.01670
Canada Americas 80.653 36319.23501

Download Buttons

Add download buttons for any file. Users can download results, data, or code.

with open("tutorial_sample.txt", "w") as f:
    f.write("This is a sample file for download.")
page.add_download("./tutorial_sample.txt", "Download Sample File")
Download Sample File

MiniPages (Horizontal Rows)

Use MiniPages to arrange multiple elements side by side (in a horizontal row).

fig1 = px.histogram(df, x="lifeExp", nbins=20)
fig2 = px.box(df, x="continent", y="gdpPercap", log_y=True)
mini = MiniPage()
mini.add_plot(fig1)
mini.add_plot(fig2)
page.add_minipage(mini)

MiniPages: Mixed Content

MiniPages can mix text, plots, tables, and code side by side. Here are two examples:

mini1 = MiniPage()
mini1.add_text("Box plot shows GDP per capita by continent.")
mini1.add_plot(fig2)

mini2 = MiniPage()
mini2.add_table(df2.head(3))
mini2.add_syntax('print("MiniPage with a table and code")', language="python")

page.add_minipage(mini1)
page.add_minipage(mini2)

Box plot shows GDP per capita by continent.

country continent lifeExp gdpPercap
Japan Asia 82.603 31656.06806
Hong Kong, China Asia 82.208 39724.97867
Iceland Europe 81.757 36180.78919
print("MiniPage with a table and code")

Syntax Highlighted Code

Show code in any language with syntax highlighting, copy, and view-raw buttons. A header above each block shows the language.

Python Example

def greet(name):
    return f"Hello, {name}"

Javascript Example

console.log("Hello, world!");

Sql Example

SELECT * FROM users WHERE active = 1;

Markup Example

<div>Hello</div>

Bash Example

echo "Deploy complete."

Json Example

{
  "key": "value",
  "count": 42
}

C Example

#include <stdio.h>
int main() { printf("Hi"); return 0; }

Combining Features

You can mix all features—plots, tables, code, downloads, and MiniPages—on a single page.

mini = MiniPage()
mini.add_plot(fig1)
mini.add_table(df2.head(5))
mini.add_syntax("print('Hello from MiniPage')", language="python")
page.add_minipage(mini)
page.add_table(df2)
country continent lifeExp gdpPercap
Japan Asia 82.603 31656.06806
Hong Kong, China Asia 82.208 39724.97867
Iceland Europe 81.757 36180.78919
Switzerland Europe 81.701 37506.41907
Australia Oceania 81.235 34435.36744
print('Hello from MiniPage')
country continent lifeExp gdpPercap
Japan Asia 82.603 31656.06806
Hong Kong, China Asia 82.208 39724.97867
Iceland Europe 81.757 36180.78919
Switzerland Europe 81.701 37506.41907
Australia Oceania 81.235 34435.36744
Spain Europe 80.941 28821.06370
Sweden Europe 80.884 33859.74835
Israel Asia 80.745 25523.27710
France Europe 80.657 30470.01670
Canada Americas 80.653 36319.23501

Export HTML

When you're ready, export your dashboard to static HTML files. This generates an `index.html` (multi-page app) and a separate HTML file for each page.

dashboard.publish(output_dir="tutorial_output")