Skip to content

Export as HTML doesn't preserve control states #8613

@dimk90

Description

@dimk90

Describe the bug

The "Download as HTML (except code)" feature correctly saves cell outputs, except for widget/control states:

Notebook state at the export moment Exported HTML
Image Image

What is missing from the export:

  • The dropdown state should be "Critical" instead of the default "Normal".
  • The selected files should be shown in the file browser control instead of an infinite spinner.
  • The plotly graph's selection state is not preserved: all curves are visible instead of only the two that were selected.

Will you submit a PR?

  • Yes

Environment

\`\`\`

{
"marimo": "0.20.4",
"editable": false,
"location": "/home/dmitry/projects/python/marimo/.venv/lib/python3.12/site-packages/marimo",
"OS": "Linux",
"OS Version": "6.6.87.2-microsoft-standard-WSL2",
"Processor": "",
"Python Version": "3.12.12",
"Locale": "--",
"Binaries": {
"Browser": "--",
"Node": "v25.7.0",
"uv": "0.10.7 (08ab1a344 2026-02-27)"
},
"Dependencies": {
"click": "8.3.1",
"docutils": "0.22.4",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.10.2",
"narwhals": "2.17.0",
"packaging": "26.0",
"psutil": "7.2.2",
"pygments": "2.19.2",
"pymdown-extensions": "10.21",
"pyyaml": "6.0.3",
"starlette": "0.52.1",
"tomlkit": "0.14.0",
"typing-extensions": "4.15.0",
"uvicorn": "0.41.0",
"websockets": "16.0"
},
"Optional Dependencies": {
"loro": "1.10.3",
"pandas": "3.0.1"
},
"Experimental Flags": {}
}

Code to reproduce

\`\`\`python

import marimo

__generated_with = "0.20.4"
app = marimo.App(width="medium")

@app.cell
def _():
import marimo as mo

return (mo,)

@app.cell
def _():
# pip install "plotly[express]"
# pip install pandas
import plotly.express as px

return (px,)

@app.cell
def _(mo):
ui_options = mo.ui.dropdown(options=['Normal', 'Warning', 'Critical'], label='Status: ', value='Normal')
return (ui_options,)

@app.cell
def _(mo, ui_options):
mo.vstack([
ui_options,
mo.md(f'The situation: {ui_options.value}'),
])
return

@app.cell(hide_code=True)
def _(mo):
mo.md(r"""
---
""")
return

@app.cell
def _(mo):
ui_file_selector = mo.ui.file_browser(initial_path='.')
ui_file_selector
return

@app.cell(hide_code=True)
def _(mo):
mo.md(r"""
---
""")
return

@app.cell
def _(mo, px):
df = px.data.gapminder().query("country in ['Canada', 'United States', 'Finland','Switzerland']")

fig = px.line(df, y="lifeExp", x="year", color="country")
fig.update_traces(textposition="bottom right")
mo.as_html(fig)
return

@app.cell
def _():
return

if name == "main":
app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions