Skip to content

Pages

Reports on Datapane can have multiple pages, which are presented to users as tabs at the top of your report. These can be used similarly to sheets in an Excel document.

To add a page, use the dp.Page block at the top-level of your report, and give it a title with the title parameter.

Info

Pages cannot be nested, and can only exist at the root level of your dp.Report object. If you're using pages, all other blocks must be contained inside a Page block.

Simple Pages

import seaborn as sns
import altair as alt
import datapane as dp

titanic = sns.load_dataset("titanic")

points = (
    alt.Chart(titanic)
    .mark_point()
    .encode(
        x="age:Q",
        color="class:N",
        y="fare:Q",
    )
    .interactive()
    .properties(width="container")
)

report = dp.Report(
    dp.Page(title="Titanic Dataset", blocks=["### Dataset", titanic]),
    dp.Page(title="Titanic Plot", blocks=["### Plot", points]),
)

report.save(path="simple-page.html")

Pages with side navigation

import seaborn as sns
import altair as alt
import datapane as dp

titanic = sns.load_dataset("titanic")

points = (
    alt.Chart(titanic)
    .mark_point()
    .encode(
        x="age:Q",
        color="class:N",
        y="fare:Q",
    )
    .interactive()
    .properties(width="container")
)

report = dp.Report(
    dp.Page(title="Titanic Dataset", blocks=["### Dataset", titanic]),
    dp.Page(title="Titanic Plot", blocks=["### Plot", points]),
    layout=dp.PageLayout.SIDE,
)

report.save(path="page-side-nav.html")