| 398 | |
| 399 | @workflow.atom() |
| 400 | def checkbox_demo(): |
| 401 | text("## 12. Adding Interactivity with `checkbox()`") |
| 402 | text( |
| 403 | "The `checkbox()` function allows users to select or deselect an option using a checkbox." |
| 404 | ) |
| 405 | |
| 406 | # Simple checkbox example |
| 407 | is_selected = checkbox(label="Select me!") |
| 408 | |
| 409 | # Show the checkbox state |
| 410 | if is_selected: |
| 411 | text("✅ Checkbox is selected!") |
| 412 | else: |
| 413 | text("⬜ Checkbox is not selected") |
| 414 | |
| 415 | text( |
| 416 | """ |
| 417 | The `checkbox()` component creates an interactive checkbox input. |
| 418 | **Example:** |
| 419 | ```python |
| 420 | from preswald import checkbox |
| 421 | |
| 422 | # Basic usage |
| 423 | is_checked = checkbox( |
| 424 | label="Enable feature", |
| 425 | default=False |
| 426 | ) |
| 427 | |
| 428 | # Use the checkbox value in your app |
| 429 | if is_checked: |
| 430 | # Do something when checked |
| 431 | print("Feature enabled!") |
| 432 | ``` |
| 433 | |
| 434 | The checkbox returns a boolean value that you can use to control your app's behavior. |
| 435 | """ |
| 436 | ) |
| 437 | |
| 438 | |
| 439 | @workflow.atom() |