Skip to main content

mo.ui.text

Create a text input field for user input.

Signature

mo.ui.text(
    value: str = "",
    placeholder: str = "",
    kind: Literal["text", "password", "email", "url"] = "text",
    max_length: int | None = None,
    disabled: bool = False,
    debounce: bool | int = True,
    *,
    label: str = "",
    on_change: Callable[[str], None] | None = None,
    full_width: bool = False
)

Parameters

value
str
default:"''"
Initial text value
placeholder
str
default:"''"
Placeholder text shown when empty
kind
'text' | 'password' | 'email' | 'url'
default:"'text'"
Type of input field
max_length
int
Maximum number of characters allowed
disabled
bool
default:"False"
Whether the input is disabled
debounce
bool | int
default:"True"
Debounce input updates (True for default delay, or specify milliseconds)
label
str
default:"''"
Markdown label for the input
full_width
bool
default:"False"
Whether input takes full width

Examples

import marimo as mo

# Basic text input
name = mo.ui.text(placeholder="Enter your name")
name
# Email input with validation
email = mo.ui.text(
    kind="email",
    placeholder="[email protected]",
    label="**Email address**"
)
# Password input
password = mo.ui.text(
    kind="password",
    placeholder="Enter password",
    max_length=50
)
# Use the value
mo.md(f"Hello, {name.value}!")
By default, text inputs are debounced to avoid excessive updates while typing.

Build docs developers (and LLMs) love