Last active
July 22, 2025 09:19
-
-
Save barseghyanartur/6f84caf515cdbd7e23978732ef2a9d8b to your computer and use it in GitHub Desktop.
Marimo nested tabs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import marimo | |
| app = marimo.App(width="full") | |
| @app.cell | |
| def _im(): | |
| import logging | |
| import marimo as mo | |
| logger = logging.getLogger(__name__) | |
| return mo, logger | |
| @app.cell | |
| def _tabs(mo, logger): | |
| # Define the content for the nested tabs | |
| nested_tab1_content = mo.md("This is the content of Nested Tab 1") | |
| nested_tab2_content = mo.md("This is the content of Nested Tab 2") | |
| # Create the nested tabs | |
| nested_tabs = mo.ui.tabs( | |
| { | |
| "Nested Tab 1": mo.vstack([nested_tab1_content]), | |
| "Nested Tab 2": mo.vstack([nested_tab2_content]), | |
| }, | |
| on_change=lambda _value: logger.info(f"Nested Tab: {_value}"), | |
| ) | |
| # Define the content for the main tabs | |
| main_tab1_content = nested_tabs | |
| main_tab2_content = mo.md("This is the content of Main Tab 2") | |
| # Create the main tabs | |
| main_tabs = mo.ui.tabs( | |
| { | |
| "Main Tab 1": mo.vstack([mo.vstack([main_tab1_content])]), | |
| "Main Tab 2": mo.vstack([mo.vstack([main_tab2_content])]), | |
| }, | |
| on_change=lambda _value: logger.info(f"Main Tab: {_value}"), | |
| ) | |
| # Display the main tabs | |
| main_tabs | |
| if __name__ == "__main__": | |
| app.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import marimo | |
| app = marimo.App(width="full") | |
| @app.cell | |
| def _im(): | |
| import logging | |
| import marimo as mo | |
| logger = logging.getLogger(__name__) | |
| return mo, logger | |
| @app.cell | |
| def _tabs(mo, logger): | |
| # Define the content for the nested tabs | |
| nested_tab1_content = mo.md("This is the content of Nested Tab 1") | |
| nested_tab2_content = mo.md("This is the content of Nested Tab 2") | |
| # Create the nested tabs | |
| nested_tabs = mo.ui.tabs( | |
| { | |
| "Nested Tab 1": mo.vstack([nested_tab1_content]), | |
| "Nested Tab 2": mo.vstack([nested_tab2_content]), | |
| }, | |
| on_change=lambda _value: print(f"Nested Tab: {_value}"), | |
| ) | |
| # Define the content for the main tabs | |
| main_tab1_content = nested_tabs | |
| main_tab2_content = mo.md("This is the content of Main Tab 2") | |
| # Create the main tabs | |
| main_tabs = mo.ui.tabs( | |
| { | |
| "Main Tab 1": mo.vstack([mo.vstack([main_tab1_content])]), | |
| "Main Tab 2": mo.vstack([mo.vstack([main_tab2_content])]), | |
| }, | |
| on_change=lambda _value: print(f"Main Tab: {_value}"), | |
| ) | |
| # Display the main tabs | |
| main_stack = mo.vstack([main_tabs]) | |
| return main_stack | |
| @app.cell | |
| def _interface(mo, main_stack): | |
| main_stack if True else mo.md("Hello") | |
| if __name__ == "__main__": | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment