Skip to content

Commit b353acd

Browse files
5 - HTML Inputs for Dynamic Content Changes
1 parent 3549036 commit b353acd

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

full_stack_python/full_stack_python.py

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

88
class State(rx.State):
99
"""The app state."""
10-
label = "This is my label"
11-
orginal_label = "This is my label"
10+
label = "Welcome to Reflex!"
1211

13-
def change_label(self):
14-
if self.label == "Cool label.":
15-
self.label = self.orginal_label
16-
else:
17-
self.label = "Cool label."
12+
def handle_title_input_change(self, val):
13+
self.label = val
14+
15+
def did_click(self):
16+
print("Hello world did click")
1817

1918

2019
def index() -> rx.Component:
2120
# Welcome Page (Index)
2221
return rx.container(
2322
rx.color_mode.button(position="bottom-left"),
2423
rx.vstack(
25-
rx.heading(State.label, " Welcome to Reflex!", size="9"),
24+
rx.heading(State.label, size="9"),
2625
rx.text(
2726
"Get started by editing ",
2827
rx.code(f"{config.app_name}/{config.app_name}.py"),
29-
on_click=State.change_label,
3028
size="5",
3129
),
32-
# rx.button("Do something!", on_click=State.change_label),
30+
# <input type='text' value='My value' />
31+
rx.input(
32+
default_value=State.label,
33+
on_click=State.did_click,
34+
on_change=State.handle_title_input_change
35+
),
3336
rx.link(
3437
rx.button("Check out our docs!"),
3538
href="https://reflex.dev/docs/getting-started/introduction/",

0 commit comments

Comments
 (0)