Skip to content

Commit 3549036

Browse files
4 - Dynamic Content and on_click Events
1 parent b54002d commit 3549036

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

full_stack_python/full_stack_python.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,29 @@
77

88
class State(rx.State):
99
"""The app state."""
10+
label = "This is my label"
11+
orginal_label = "This is my label"
1012

11-
...
13+
def change_label(self):
14+
if self.label == "Cool label.":
15+
self.label = self.orginal_label
16+
else:
17+
self.label = "Cool label."
1218

1319

1420
def index() -> rx.Component:
1521
# Welcome Page (Index)
1622
return rx.container(
1723
rx.color_mode.button(position="bottom-left"),
1824
rx.vstack(
19-
rx.heading("Welcome to Reflex!", size="9"),
25+
rx.heading(State.label, " Welcome to Reflex!", size="9"),
2026
rx.text(
2127
"Get started by editing ",
2228
rx.code(f"{config.app_name}/{config.app_name}.py"),
29+
on_click=State.change_label,
2330
size="5",
2431
),
32+
# rx.button("Do something!", on_click=State.change_label),
2533
rx.link(
2634
rx.button("Check out our docs!"),
2735
href="https://reflex.dev/docs/getting-started/introduction/",

0 commit comments

Comments
 (0)