Batch¶
- class marimo.ui.batch(html: Html, elements: dict[str, marimo._plugins.ui._core.ui_element.UIElement[Any, Any]], on_change: Callable[[Dict[str, object]], None] | None = None)¶
- Convert an HTML object with templated text into a UI element. - A - batchis a UI element that wraps other UI elements, and is represented by custom HTML or markdown. You can create a- batchby calling the- batch()method on- Htmlobjects.- Get the value of the wrapped UI elements using the - valueattribute of the batch.- Example. - In the below example, - user_infois a UI Element whose output is markdown and whose value is a dict with keys- 'name'and- 'birthday'(and values equal to the values of their corresponding elements).- user_info = mo.md( ''' - What's your name?: {name} - When were you born?: {birthday} ''' ).batch(name=mo.ui.text(), birthday=mo.ui.date()) - To get the value of - nameand- birthday, use:- user_info.value - You can also instantiate this class directly: - markdown = mo.md( ''' - What's your name?: {name} - When were you born?: {birthday} ''' ) batch = mo.ui.batch( markdown, {"name": mo.ui.text(), "birthday": mo.ui.date()} ) - Attributes. - value: a- dictof the batched elements’ values
- elements: a- dictof the batched elements (clones of the originals)
- on_change: optional callback to run when this element’s value changes
 - Initialization Args. - html: a templated - Htmlobject
- elements: the UI elements to interpolate into the HTML template 
- on_change: optional callback to run when this element’s value changes
 - Public methods - Inherited from- _batch_base- get(key[, default])- items()- values()- Inherited from- UIElement- form([label, bordered, loading, ...])- Create a submittable form out of this - UIElement.- send_message(message, buffers)- Send a message to the element rendered on the frontend from the backend. - Inherited from- Html- batch(**elements)- Convert an HTML object with templated text into a UI element. - center()- Center an item. - right()- Right-justify. - left()- Left-justify. - callout([kind])- Create a callout containing this HTML element. - style(style)- Wrap an object in a styled container. - Public Data Attributes: - Inherited from- _batch_base- elements- Inherited from- UIElement- value- The element’s current value. - Inherited from- Html- text- A string of HTML representing this element.