|
7 | 7 |
|
8 | 8 | class State(rx.State):
|
9 | 9 | """The app state."""
|
10 |
| - label = "This is my label" |
11 |
| - orginal_label = "This is my label" |
| 10 | + label = "Welcome to Reflex!" |
12 | 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." |
| 12 | + def handle_title_input_change(self, val): |
| 13 | + self.label = val |
| 14 | + |
| 15 | + def did_click(self): |
| 16 | + print("Hello world did click") |
18 | 17 |
|
19 | 18 |
|
20 | 19 | def index() -> rx.Component:
|
21 | 20 | # Welcome Page (Index)
|
22 | 21 | return rx.container(
|
23 | 22 | rx.color_mode.button(position="bottom-left"),
|
24 | 23 | rx.vstack(
|
25 |
| - rx.heading(State.label, " Welcome to Reflex!", size="9"), |
| 24 | + rx.heading(State.label, size="9"), |
26 | 25 | rx.text(
|
27 | 26 | "Get started by editing ",
|
28 | 27 | rx.code(f"{config.app_name}/{config.app_name}.py"),
|
29 |
| - on_click=State.change_label, |
30 | 28 | size="5",
|
31 | 29 | ),
|
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 | + ), |
33 | 36 | rx.link(
|
34 | 37 | rx.button("Check out our docs!"),
|
35 | 38 | href="https://reflex.dev/docs/getting-started/introduction/",
|
|
0 commit comments