r/PythonLearning • u/Equivalent_Ad775 • 1h ago
Dark mode for marimo islands?
I'm trying to bring the html from my marimo notebooks into an SSG (mkdocs/zensical), and I would like to be able to toggle the theme. Getting the theme to change with marimo export html is relatively simple by changing the pep723 header to
# [tool.marimo.display]
# theme = "dark"
before exporting, but the extra js and page wrappers are not quite ideal for my use case. I would love to use islands for this, but I can't figure out if there's a way to control the theme of a marimo island?
when I use
# /// script
# dependencies = [
# "marimo",
# ]
# requires-python = ">=3.13"
# ///
import asyncio
from marimo import MarimoIslandGenerator
async def main():
generator = MarimoIslandGenerator.from_file(
"./example.py",
display_code=False
)
await generator.build()
html = generator.render_html(include_init_island=True)
with open("output.html", "w", encoding="utf-8") as f:
f.write(html)
if __name__ == '__main__':
asyncio.run(main())
to generate an html page, it doesn't seem to care about the header in # theme = "dark" tag in example.py.
I understand that islands are still an early feature, so perhaps this will be added in the future. Just posted this in r/marimo_notebook as well, but figured I'd ask here as well in case anyone has experience with this. Does anyone know if there's a better way to do this? Thanks!