Py.Cafe

maartenbreddels/

redacted-threshold

Dashboard for tracking button clicks with color change (Solara)

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import solara

clicks = solara.reactive(0)


@solara.component
def Page():
    color = "green"
    if clicks.value >= 5:
        color = "red"

    def increment():
        clicks.value += 1
        print("clicks", clicks)  # noqa
        

    solara.Button(label=f"Clicked: {clicks}", on_click=increment, color=color)