Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

docs: Add `button.py` and modify preview (#3342)

Srihari Thyagarajan2ecd53e21312
diff --git a/docs/api/inputs/button.md b/docs/api/inputs/button.md
index 15fae0b2a6..a4c60359bb 100644
--- a/docs/api/inputs/button.md
+++ b/docs/api/inputs/button.md
@@ -4,15 +4,9 @@
If you're looking for a button to trigger computation on click, consider
using [`mo.ui.run_button`][marimo.ui.run_button].
-/// marimo-embed
-
-```python
-def __():
- mo.ui.button(label="Click me")
- return
-```
+/// marimo-embed-file
+ filepath: examples/ui/button.py
///
-::: marimo.ui.button
+::: marimo.ui.button
\ No newline at end of file
diff --git a/examples/ui/button.py b/examples/ui/button.py
new file mode 100644
index 0000000000..28b07610f9
--- /dev/null
+++ b/examples/ui/button.py
@@ -0,0 +1,29 @@
+import marimo
+
+__generated_with = "0.10.6"
+app = marimo.App()
+
+
+def _():
+ import marimo as mo
+ return (mo,)
+
+
+def _(mo):
+ button = mo.ui.button(
+ value=0, on_click=lambda value: value + 1, label="increment", kind="warn"
+ )
+ button
+ return (button,)
+
+
+def _(button):
+ button.value
+ return
+
+
+if __name__ == "__main__":
+ app.run()