marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.35k stars 156 forks source link

marimo.app_meta.theme #1624

Open metaboulie opened 2 weeks ago

metaboulie commented 2 weeks ago

Description

Add a marimo.settings, to control or only read the settings if controlling setting in cell will interrupt the notebook.

Suggested solution

Why this feature can be useful: We can use the value of marimo.settings.width, marimo.setting.theme, etc to render some ui. for instance, plotly, when specifying a figure's layout, we can do the following:

template = 'plotly_dark` if marimo.settings.theme == 'dark' else 'plotly_white'
fig.update_layout(
    template=template
)

then we can get a dark plotly figure in dark mode and a light one in light mode

Alternative

No response

Additional context

No response

mscolnick commented 2 weeks ago

We should expose the theme for sure - not sure if we need all the other settings.

We can put this in AppMetadata.

mscolnick commented 2 weeks ago

Also - it would be nice if marimo could handle these setting under the hood (but can be turned off).

e.g. marimo.theme.autohandle_third_party()

mscolnick commented 2 weeks ago

@metaboulie - i updated the title to add marimo.app_meta.theme. We can think about adding more settings there over time for specific use-cases

For the implementor: We have something already called AppMetadata. That is currently an internal class that we probably don't want to expose everything in there. So we can rename that, or come up with another name for what marimo.app_meta is