Date

class marimo.ui.date(start: dt.date | str | None = None, stop: dt.date | str | None = None, value: dt.date | str | None = None, *, label: str = '', on_change: Callable[[dt.date], None] | None = None, full_width: bool = False)

A date picker with an optional start and stop date.

Example.

# initialize the date picker at a given date
date = mo.ui.date(value="2022-01-01")
# when value is omitted, date picker initializes with today's date
date = mo.ui.date()
# create a date picker with bounds
date = mo.ui.date(
    value="2022-06-01",
    start="2022-01-01",
    stop="2022-12-31",
)

Attributes.

  • value: a str (YYYY-MM-DD) or datetime.date object of the chosen date

  • start: the start date

  • stop: the stop date

Initialization Args.

  • start: minimum date selectable; if None, defaults to 01-01-0001

  • stop: maximum date selectable; if None, defaults to 12-31-9999

  • value: default date

    • if None and start and stop are None, defaults to the current day;

    • else if None and start is not None, defaults to start;

    • else if None and stop is not None, defaults to stop

  • label: text label for the element

  • on_change: optional callback to run when this element’s value changes

  • full_width: whether the input should take up the full width of its container

Public methods

Inherited from UIElement

form([label, bordered, loading, ...])

Create a submittable form out of this UIElement.

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:

DATEFORMAT

start

stop

Inherited from UIElement

value

The element’s current value.

Inherited from Html

text

A string of HTML representing this element.