Skip to main content

marimo-pydantic-form

[!WARNING] This package is under active development. Features and APIs may change.

A Python package for building marimo forms from Pydantic models.

[!NOTE] Currently, UI elements must be manually assigned to each field. Automatic UI element generation is planned for future releases.

Features

  • Automatically generate marimo forms from Pydantic models
  • Support for nested Pydantic models
  • Customizable UI elements for each field
  • Type-safe form validation using Pydantic
  • Easy parsing of form values back into Pydantic model instances

Installation

pip install marimo-pydantic-form

Or using uv:

uv add marimo-pydantic-form

Quick Start

import marimo as mo
from pydantic import BaseModel
from marimo_pydantic_form import PydanticFormBuilder

class Inner(BaseModel):
    a: int

class Model(BaseModel):
    x: float
    y: Inner

# Create a form builder with custom UI elements
builder = PydanticFormBuilder(
    model=Model,
    ui={
        "x": mo.ui.slider(0, 100, label="x"),
        "y.a": mo.ui.slider(0, 100, label="y.a")
    },
)

# Build the form
form = builder.build()

# Parse the form value into a Pydantic model instance
model_instance = builder.parse(form.value)

Usage

Basic Form

Create a form from a Pydantic model:

from marimo_pydantic_form import PydanticFormBuilder

builder = PydanticFormBuilder(model=YourModel)
form = builder.build()

Custom UI Elements

Assign custom marimo UI elements to specific fields using dot notation for nested fields:

builder = PydanticFormBuilder(
    model=Model,
    ui={
        "field_name": mo.ui.text(label="Custom Label"),
        "nested.field": mo.ui.slider(0, 100)
    }
)

Parsing Form Values

Convert form values back to Pydantic model instances:

model_instance = builder.parse(form.value)

License

See LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marimo_pydantic_form-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marimo_pydantic_form-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file marimo_pydantic_form-0.1.1.tar.gz.

File metadata

  • Download URL: marimo_pydantic_form-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for marimo_pydantic_form-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bc0b369e6b2dbe6ae29665e41022e632d1bc3daa2e65eb5b08b78324d8e24ce6
MD5 415c6c6ad8e4862324ba30d31d33e5c1
BLAKE2b-256 1a0a61144d7095476c01487cdafbef52f85fa8137e1c45ac1516006cb07aaa6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for marimo_pydantic_form-0.1.1.tar.gz:

Publisher: release.yaml on shunichironomura/marimo-pydantic-form

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file marimo_pydantic_form-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for marimo_pydantic_form-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e5c6d609b4ffb08a45f4f78e8d23c62cf0934facd71f3c500e915699347334
MD5 4aee843a5e9ef979df2d104086c5d32b
BLAKE2b-256 01ec71c33e7d3ea137c6a6a2149594f86c9c819a7f9e967956de1cc08d8e54c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for marimo_pydantic_form-0.1.1-py3-none-any.whl:

Publisher: release.yaml on shunichironomura/marimo-pydantic-form

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page