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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Update routes docs (#1453)
Akshay Agrawalef1c780bbfbc
diff --git a/docs/api/layouts/routes.md b/docs/api/layouts/routes.mdindex 385e7e4c6e..e814fce8ab 100644--- a/docs/api/layouts/routes.md+++ b/docs/api/layouts/routes.md@@ -1,41 +1,52 @@# Routes```{eval-rst}-.. marimo-embed::- :size: medium-- @app.cell- def __():- mo.sidebar(- [- mo.md("# marimo"),- mo.nav_menu(- {- "#/": f"{mo.icon('lucide:home')} Home",- "#/about": f"{mo.icon('lucide:user')} About",- "#/contact": f"{mo.icon('lucide:phone')} Contact",- "Links": {- "https://twitter.com/marimo_io": "Twitter",- "https://github.com/marimo-team/marimo": "GitHub",- },- },- orientation="vertical",- ),- ]- )- return-- @app.cell- def __():- mo.routes({- "#/": mo.md("# Home"),- "#/about": mo.md("# About"),- "#/contact": mo.md("# Contact"),- mo.routes.CATCH_ALL: mo.md("# Home"),- })- return+.. autofunction:: marimo.routes```-```{eval-rst}-.. autofunction:: marimo.routes+## Full example with a sidebar++Here is a marimo program that uses routes with a sidebar.++```python+import marimo++app = marimo.App()++def __():+ import marimo as mo+ return+++def __():+ mo.sidebar(+ [+ mo.md("# marimo"),+ mo.nav_menu(+ {+ "#/": f"{mo.icon('lucide:home')} Home",+ "#/about": f"{mo.icon('lucide:user')} About",+ "#/contact": f"{mo.icon('lucide:phone')} Contact",+ "Links": {+ "https://twitter.com/marimo_io": "Twitter",+ "https://github.com/marimo-team/marimo": "GitHub",+ },+ },+ orientation="vertical",+ ),+ ]+ )+ return++def __():+ mo.routes({+ "#/": mo.md("# Home"),+ "#/about": mo.md("# About"),+ "#/contact": mo.md("# Contact"),+ mo.routes.CATCH_ALL: mo.md("# Home"),+ })+ return```diff --git a/marimo/_plugins/stateless/routes.py b/marimo/_plugins/stateless/routes.pyindex 39848bbbb8..633fae7ab0 100644--- a/marimo/_plugins/stateless/routes.py+++ b/marimo/_plugins/stateless/routes.py@@ -21,7 +21,7 @@ class routes(UIElement[str, str]):see these features, please let us know on GitHub:https://github.com/marimo-team/marimo/issues- For a simple-page-application (SPA) experience, use+ For a simple-page-application (SPA) experience, youshould use hash-based routing. For example, prefixyour routes with `#/`.