One of marimo’s most powerful features is its first-class support for interactive user interface (UI) elements: interacting with a UI element will automatically run cells that reference it. ## marimo.ui
The marimo.ui module has a library of pre-built elements.For example, here's a slider: slider%20%3D%20mo.ui.slider(start%3D1%2C%20stop%3D10%2C%20step%3D1)%0Aslider%0A%0Amo.md(%0A%20%20%20%20f%22%22%22%0A%20%20%20%20The%20%60marimo.ui%60%20module%20has%20a%20library%20of%20pre-built%20elements.%0A%0A%20%20%20%20For%20example%2C%20here's%20a%20%60slider%60%3A%20%7Bslider%7D%0A%20%20%20%20%22%22%22%0A)and here's its value: 1.mo.md(f%22and%20here's%20its%20value%3A%20**%7Bslider.value%7D**.%22)
How interactions run cells
Whenever you interact with a UI element, its value is sent back to Python. When this happens, all cells that reference the global variable bound to the UI element, but don’t define it, will run.
This simple rule lets you use UI elements to drive the execution of your program, letting you build interactive notebooks and tools for yourselves and others.
Interacting with a displayed UI element will only
trigger reactive execution if the UI element is assigned
to a global variable.
Every UI element has a value attribute that you can access in
Python.
You can embed UI elements in markdown using f-strings.For example, we can render the slider here:
%22Run%20button%20was%20clicked!%22%20if%20run_button.value%20else%20%22Click%20the%20run%20button!%22file_upload%20%3D%20mo.ui.file(kind%3D%22area%22)%0Afile_uploadfile_upload.valueTo see more examples, use this dropdown: mo.md(f%22To%20see%20more%20examples%2C%20use%20this%20dropdown%3A%20%7Bbasic_ui_elements%7D%22)selected_element%20%3D%20construct_element(basic_ui_elements.value)%0Ashow_element(selected_element)value(selected_element)documentation(basic_ui_elements.value)
Composite elements
Composite elements are advanced elements
let you build UI elements out of other UI elements.
Use these powerful elements to logically group together related elements,
create a dynamic set of UI elements, or reduce the number of global
variables in your program.
This first example shows how to create an array of UI elements using mo.ui.array. When you interact with an element in the array, all cells that reference the array are reactively run. If you instead used a regular Python list, cells referring to the list would not be run.
marimo also comes with mo.ui.dictionary, which is analogous to mo.ui.array
dictionary%20%3D%20mo.ui.dictionary(%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22text%22%3A%20mo.ui.text()%2C%0A%20%20%20%20%20%20%20%20%22slider%22%3A%20mo.ui.slider(start%3D1%2C%20stop%3D10)%2C%0A%20%20%20%20%20%20%20%20%22date%22%3A%20mo.ui.date()%2C%0A%20%20%20%20%7D%0A)%0Adictionarydictionary.valueTo see additional composite elements, use this dropdown: mo.md(%0A%20%20%20%20f%22To%20see%20additional%20composite%20elements%2C%20use%20this%20dropdown%3A%20%7Bcomposite_elements%7D%22%0A)composite_element%20%3D%20construct_element(composite_elements.value)%0Ashow_element(composite_element)value(composite_element)documentation(composite_elements.value)
Building custom elements
marimo supports third-party UI elements through anywidget — this lets you build your own interactive UI elements, or use widgets built by others in the community. To learn more, see our docs. ## Appendix The remaining cells are helper data structures and functions. You can look at their code if you’re curious how certain parts of this tutorial were implemented.
composite_elements%20%3D%20mo.ui.dropdown(%0A%20%20%20%20options%3Ddict(%0A%20%20%20%20%20%20%20%20sorted(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22array%22%3A%20mo.ui.array%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22batch%22%3A%20mo.ui.batch%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22dictionary%22%3A%20mo.ui.dictionary%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22form%22%3A%20mo.ui.form%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D.items()%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%2C%0A%20%20%20%20allow_select_none%3DTrue%0A)basic_ui_elements%20%3D%20mo.ui.dropdown(%0A%20%20%20%20options%3Ddict(%0A%20%20%20%20%20%20%20%20sorted(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22button%22%3A%20mo.ui.button%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22checkbox%22%3A%20mo.ui.checkbox%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22date%22%3A%20mo.ui.date%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22dropdown%22%3A%20mo.ui.dropdown%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22file%22%3A%20mo.ui.file%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22multiselect%22%3A%20mo.ui.multiselect%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22number%22%3A%20mo.ui.number%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22radio%22%3A%20mo.ui.radio%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22range_slider%22%3A%20mo.ui.range_slider%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22slider%22%3A%20mo.ui.slider%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22switch%22%3A%20mo.ui.switch%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22tabs%22%3A%20mo.ui.tabs%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22table%22%3A%20mo.ui.table%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22text%22%3A%20mo.ui.text%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22text_area%22%3A%20mo.ui.text_area%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D.items()%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%2C%0A)def%20construct_element(value)%3A%0A%20%20%20%20if%20value%20%3D%3D%20mo.ui.array%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.array(%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Bmo.ui.text()%2C%20mo.ui.slider(1%2C%2010)%2C%20mo.ui.date()%5D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.batch%3A%0A%20%20%20%20%20%20%20%20return%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20Name%3A%20%7Bname%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20Date%3A%20%7Bdate%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20).batch(name%3Dmo.ui.text()%2C%20date%3Dmo.ui.date())%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.button%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.button(%0A%20%20%20%20%20%20%20%20%20%20%20%20value%3D0%2C%20label%3D%22click%20me%22%2C%20on_click%3Dlambda%20value%3A%20value%20%2B%201%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.checkbox%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.checkbox(label%3D%22check%20me%22)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.date%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.date()%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.dictionary%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.dictionary(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22slider%22%3A%20mo.ui.slider(1%2C%2010)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22text%22%3A%20mo.ui.text(%22type%20something!%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22array%22%3A%20mo.ui.array(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.button(value%3D0%2C%20on_click%3Dlambda%20v%3A%20v%20%2B%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20_%20in%20range(3)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22buttons%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.dropdown%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.dropdown(%5B%22a%22%2C%20%22b%22%2C%20%22c%22%5D)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.file%3A%0A%20%20%20%20%20%20%20%20return%20%5Bmo.ui.file(kind%3D%22button%22)%2C%20mo.ui.file(kind%3D%22area%22)%5D%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.form%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.text_area(placeholder%3D%22...%22).form()%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.multiselect%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.multiselect(%5B%22a%22%2C%20%22b%22%2C%20%22c%22%5D)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.number%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.number(start%3D1%2C%20stop%3D10%2C%20step%3D0.5)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.radio%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.radio(%5B%22a%22%2C%20%22b%22%2C%20%22c%22%5D%2C%20value%3D%22a%22)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.range_slider%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.range_slider(start%3D1%2C%20stop%3D10%2C%20step%3D0.5)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.slider%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.slider(start%3D1%2C%20stop%3D10%2C%20step%3D0.5)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.switch%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.switch()%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.tabs%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.tabs(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Employee%20%231%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22first_name%22%3A%20%22Michael%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22last_name%22%3A%20%22Scott%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Employee%20%232%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22first_name%22%3A%20%22Dwight%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22last_name%22%3A%20%22Schrute%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.table%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.table(%0A%20%20%20%20%20%20%20%20%20%20%20%20data%3D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%22first_name%22%3A%20%22Michael%22%2C%20%22last_name%22%3A%20%22Scott%22%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%22first_name%22%3A%20%22Dwight%22%2C%20%22last_name%22%3A%20%22Schrute%22%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Employees%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.text%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.text()%0A%20%20%20%20elif%20value%20%3D%3D%20mo.ui.text_area%3A%0A%20%20%20%20%20%20%20%20return%20mo.ui.text_area()%0A%20%20%20%20return%20Nonedef%20show_element(element)%3A%0A%20%20%20%20if%20element%20is%20not%20None%3A%0A%20%20%20%20%20%20%20%20return%20mo.hstack(%5Belement%5D%2C%20justify%3D%22center%22)def%20value(element)%3A%0A%20%20%20%20if%20element%20is%20not%20None%3A%0A%20%20%20%20%20%20%20%20v%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20element.value%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20isinstance(element%2C%20mo.ui.file)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20element.name()%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20return%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20The%20element's%20current%20value%20is%20%7Bmo.as_html(element.value)%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20)def%20documentation(element)%3A%0A%20%20%20%20if%20element%20is%20not%20None%3A%0A%20%20%20%20%20%20%20%20return%20mo.accordion(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22Documentation%20on%20%60mo.ui.%7Belement.__name__%7D%60%22%3A%20mo.doc(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20element%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20)import%20marimo%20as%20mo Back to top
---title: Uimarimo-version: 0.13.2header: |- # Copyright 2024 Marimo. All rights reserved.filters:- marimo-team/marimo---# UI ElementsOne of marimo's most powerful features is its first-classsupport for interactive user interface (UI) elements: interactingwith a UI element will automatically run cells that reference it.<!---->## marimo.ui```python {.marimo}slider = mo.ui.slider(start=1, stop=10, step=1)slidermo.md( f""" The `marimo.ui` module has a library of pre-built elements. For example, here's a `slider`: {slider} """)``````python {.marimo}mo.md(f"and here's its value: **{slider.value}**.")```### How interactions run cellsWhenever you interact with a UI element, its value is sent back toPython. When this happens, all cells that reference the global variablebound to the UI element, but don't define it, will run.This simple rule lets you use UI elements todrive the execution of your program, letting you buildinteractive notebooks and tools for yourselves and others.```python {.marimo hide_code="true"}mo.accordion( { "Tip: assign UI elements to global variables": ( """ Interacting with a displayed UI element will only trigger reactive execution if the UI element is assigned to a global variable. """ ), "Tip: accessing an element's value": ( """ Every UI element has a value attribute that you can access in Python. """ ), "Tip: embed UI elements in markdown": mo.md( f""" You can embed UI elements in markdown using f-strings. For example, we can render the slider here: {slider} """ ), })```### Simple elements<!---->marimo has a [large library of simple UI elements](https://docs.marimo.io/api/inputs/index.html). Here are a just few examples:```python {.marimo hide_code="true"}mo.md( """ See our [examples folder](https://github.com/marimo-team/marimo/tree/main/examples/ui) on GitHub for bite-sized notebooks showcasing all our UI elements. For a more detailed reference, see our [API docs](https://docs.marimo.io/api/inputs/). """).callout()``````python {.marimo}number = mo.ui.number(start=1, stop=10, step=1)number``````python {.marimo}number.value``````python {.marimo}checkbox = mo.ui.checkbox(label="checkbox")checkbox``````python {.marimo}checkbox.value``````python {.marimo}text = mo.ui.text(placeholder="type some text ...")text``````python {.marimo}text.value``````python {.marimo}text_area = mo.ui.text_area(placeholder="type some text ...")text_area``````python {.marimo}text_area.value``````python {.marimo}dropdown = mo.ui.dropdown(["a", "b", "c"])dropdown``````python {.marimo}dropdown.value``````python {.marimo}run_button = mo.ui.run_button(label="click me")run_button``````python {.marimo}"Run button was clicked!" if run_button.value else "Click the run button!"``````python {.marimo}file_upload = mo.ui.file(kind="area")file_upload``````python {.marimo}file_upload.value``````python {.marimo}mo.md(f"To see more examples, use this dropdown: {basic_ui_elements}")``````python {.marimo}selected_element = construct_element(basic_ui_elements.value)show_element(selected_element)``````python {.marimo}value(selected_element)``````python {.marimo}documentation(basic_ui_elements.value)```### Composite elements Composite elements are advanced elements let you build UI elements out of other UI elements. Use these powerful elements to logically group together related elements, create a dynamic set of UI elements, or reduce the number of global variables in your program.<!---->This first example shows how to create an array of UI elements using `mo.ui.array`.When you interact with an element in the array, all cells that reference thearray are reactively run. If you instead used a regular Python list, cells referring to the list would _not_ be run.```python {.marimo}array = mo.ui.array( [mo.ui.text(), mo.ui.slider(start=1, stop=10), mo.ui.date()])array``````python {.marimo}array.value```marimo also comes with `mo.ui.dictionary`, which is analogous to `mo.ui.array````python {.marimo}dictionary = mo.ui.dictionary( { "text": mo.ui.text(), "slider": mo.ui.slider(start=1, stop=10), "date": mo.ui.date(), })dictionary``````python {.marimo}dictionary.value``````python {.marimo hide_code="true"}mo.md( f"To see additional composite elements, use this dropdown: {composite_elements}")``````python {.marimo}composite_element = construct_element(composite_elements.value)show_element(composite_element)``````python {.marimo}value(composite_element)``````python {.marimo}documentation(composite_elements.value)```### Building custom elementsmarimo supports third-party UI elements through anywidget — this lets you buildyour own interactive UI elements, or use widgets built by others in thecommunity. To learn more, [see ourdocs](https://docs.marimo.io/guides/integrating_with_marimo/custom_ui_plugins.html).<!---->## AppendixThe remaining cells are helper data structures and functions.You can look at their code if you're curious how certain parts of thistutorial were implemented.```python {.marimo}composite_elements = mo.ui.dropdown( options=dict( sorted( { "array": mo.ui.array, "batch": mo.ui.batch, "dictionary": mo.ui.dictionary, "form": mo.ui.form, }.items() ) ), allow_select_none=True)``````python {.marimo}basic_ui_elements = mo.ui.dropdown( options=dict( sorted( { "button": mo.ui.button, "checkbox": mo.ui.checkbox, "date": mo.ui.date, "dropdown": mo.ui.dropdown, "file": mo.ui.file, "multiselect": mo.ui.multiselect, "number": mo.ui.number, "radio": mo.ui.radio, "range_slider": mo.ui.range_slider, "slider": mo.ui.slider, "switch": mo.ui.switch, "tabs": mo.ui.tabs, "table": mo.ui.table, "text": mo.ui.text, "text_area": mo.ui.text_area, }.items() ) ),)``````python {.marimo}def construct_element(value): if value == mo.ui.array: return mo.ui.array( [mo.ui.text(), mo.ui.slider(1, 10), mo.ui.date()] ) elif value == mo.ui.batch: return mo.md( """ - Name: {name} - Date: {date} """ ).batch(name=mo.ui.text(), date=mo.ui.date()) elif value == mo.ui.button: return mo.ui.button( value=0, label="click me", on_click=lambda value: value + 1 ) elif value == mo.ui.checkbox: return mo.ui.checkbox(label="check me") elif value == mo.ui.date: return mo.ui.date() elif value == mo.ui.dictionary: return mo.ui.dictionary( { "slider": mo.ui.slider(1, 10), "text": mo.ui.text("type something!"), "array": mo.ui.array( [ mo.ui.button(value=0, on_click=lambda v: v + 1) for _ in range(3) ], label="buttons", ), } ) elif value == mo.ui.dropdown: return mo.ui.dropdown(["a", "b", "c"]) elif value == mo.ui.file: return [mo.ui.file(kind="button"), mo.ui.file(kind="area")] elif value == mo.ui.form: return mo.ui.text_area(placeholder="...").form() elif value == mo.ui.multiselect: return mo.ui.multiselect(["a", "b", "c"]) elif value == mo.ui.number: return mo.ui.number(start=1, stop=10, step=0.5) elif value == mo.ui.radio: return mo.ui.radio(["a", "b", "c"], value="a") elif value == mo.ui.range_slider: return mo.ui.range_slider(start=1, stop=10, step=0.5) elif value == mo.ui.slider: return mo.ui.slider(start=1, stop=10, step=0.5) elif value == mo.ui.switch: return mo.ui.switch() elif value == mo.ui.tabs: return mo.ui.tabs( { "Employee #1": { "first_name": "Michael", "last_name": "Scott", }, "Employee #2": { "first_name": "Dwight", "last_name": "Schrute", }, } ) elif value == mo.ui.table: return mo.ui.table( data=[ {"first_name": "Michael", "last_name": "Scott"}, {"first_name": "Dwight", "last_name": "Schrute"}, ], label="Employees", ) elif value == mo.ui.text: return mo.ui.text() elif value == mo.ui.text_area: return mo.ui.text_area() return None``````python {.marimo}def show_element(element): if element is not None: return mo.hstack([element], justify="center")``````python {.marimo}def value(element): if element is not None: v = ( element.value if not isinstance(element, mo.ui.file) else element.name() ) return mo.md( f""" The element's current value is {mo.as_html(element.value)} """ )``````python {.marimo}def documentation(element): if element is not None: return mo.accordion( { f"Documentation on `mo.ui.{element.__name__}`": mo.doc( element ) } )``````python {.marimo}import marimo as mo```