Skip to main content

Utilities for working with marimo notebooks, including Pydantic model display and a mohtml-based design system

Project description

marimo-utils

Utilities for working with marimo notebooks.

Installation

pip install marimo-utils

Usage

@add_marimo_display() decorator

Adds a _display_ method to Pydantic models for rich rendering in marimo notebooks.

from pydantic import BaseModel
from marimo_utils import add_marimo_display

@add_marimo_display()
class MyConfig(BaseModel):
    name: str
    value: int

When a MyConfig instance is the last expression in a marimo cell, it renders with the class name, source file path, and all field values.

marimo_utils.style — design-system primitives

A small design-system for rendering Pydantic-backed "inspection cards" in marimo notebooks, built on mohtml. Tokens (ColorPalette, Typography, SpacingScale), atoms (Badge, Title, DataItem, DateStamp, ProjectStamp, LabeledList, MetaStamp), a Card composer, a css() style-builder helper, and an HtmlRenderable protocol for typing mohtml-produced values.

import marimo as mo
from marimo_utils.style import (
    Badge, Card, ColorPalette, PaletteToneName,
    SpacingScale, Title, Typography,
)

palette = ColorPalette.default()
typography = Typography.default()
spacing = SpacingScale.default()

card = Card(
    palette=palette,
    typography=typography,
    spacing=spacing,
    title=Title(
        palette=palette,
        typography=typography,
        spacing=spacing,
        drop_text="Pool Card",
        text="demo pool",
    ),
    header=Badge(
        palette=palette,
        typography=typography,
        spacing=spacing,
        label="complete",
        tone=PaletteToneName.SUCCESS,
    ).render(),
)

mo.Html(str(card.render()))

See IMPORT_STYLE.md for design notes on the mohtml leverage points and CSS helper.

Changes

0.2.0

  • Adds marimo_utils.style submodule (Card, tokens, atoms, css() helper, HtmlRenderable protocol).
  • Adds mohtml>=0.1.11 runtime dependency.

Project 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_utils-0.2.0.tar.gz (107.0 kB view details)

Uploaded Source

Built Distribution

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

marimo_utils-0.2.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file marimo_utils-0.2.0.tar.gz.

File metadata

  • Download URL: marimo_utils-0.2.0.tar.gz
  • Upload date:
  • Size: 107.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for marimo_utils-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d50499d42be5d6989d217cc4d29835b02dd6c1901f287a3dca65b05aa22188d4
MD5 3cdc7040b2701141c6e071c2aa88265c
BLAKE2b-256 849461a4b93d4fc2d8de729c6dc3fd2194d9c65e8a25e9df92635873774df8bc

See more details on using hashes here.

File details

Details for the file marimo_utils-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for marimo_utils-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 367eb696239476f66aabfc6766bc59e377d0b584a2aa37641b11c6a6ab96a3be
MD5 0a3aad824ef45f578978479f1449ece1
BLAKE2b-256 e4179a9fb8f1dfb694070edb9dee22410a5afcee11842f098706039355dec57c

See more details on using hashes here.

Supported by

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