widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.65k stars 114 forks source link

Theme can't be changed for ipywidgets and solara.Markdown widget #635

Closed egormkn closed 2 weeks ago

egormkn commented 3 weeks ago

Hello!

Changing theme with ThemeToggle does not apply to ipywidgets and solara.Markdown widget. They always use the theme that was applied during the initial page load. Here is an example page:

import textwrap

import reacton.ipywidgets as rw
import solara

@solara.component
def Layout(children):
    dark_effective = solara.lab.use_dark_effective()
    return solara.AppLayout(children=children, toolbar_dark=dark_effective, color=None)

@solara.component
def Page():
    with solara.AppBar():
        solara.lab.ThemeToggle()

    rw.Button(description="Some button")

    rw.IntText(value=7, description="Some int:", disabled=False)

    rw.HTMLMath(value=r"$\text{Some equation:}\ \int f(x) dx$")

    solara.Markdown(
        textwrap.dedent(
            r"""
            # This is a title

            ## This is a subtitle
            This is a markdown text, **bold** and *italic* text is supported.

            ## Math
            Also, $x^2$ is rendered as math.

            Or multiline math:
            $$
            \int_0^1 x^2 dx = \frac{1}{3}
            $$

            """
        )
    )

markdown

UPD: I tried to create an example on app.py.cafe, but ipywidget styles seems to be broken there.

iisakkirotko commented 3 weeks ago

Hey @egormkn!

Thanks a lot for reporting this. I think it's interesting that on solara.dev it seems like solara.Markdown body text does change theme, while titles, etc. don't. Either way, I believe I found the issue and will open a PR to fix it.