DocsDocumentation

Nitro UI

Build HTML with Python, not strings.

Build HTML with Python, not strings.

NitroUI is a zero-dependency Python library that lets you construct HTML documents using a clean, composable class-based API. No template files, no string concatenation, no runtime dependencies.

from nitro_ui import *

page = HTML(
    Head(Title("Dashboard")),
    Body(
        Nav(
            Anchor("Home", href="/"),
            Anchor("Settings", href="/settings", cls="active")
        ),
        Main(
            H1("Welcome back!"),
            Div(
                Paragraph("You have ", Strong("3"), " new notifications."),
                Button("View All", type="button", cls="btn-primary")
            )
        )
    )
)

print(page.render(pretty=True))

Why NitroUI?

  • Type-safe: IDE autocomplete and type hints for every element
  • Composable: Build reusable components as Python classes
  • Zero dependencies: Just Python 3.8+, nothing else
  • Framework agnostic: Works with FastAPI, Django, Flask, or standalone
  • Serializable: Convert to/from JSON for drag-and-drop builders
  • Secure by default: Automatic HTML escaping, CSS injection prevention, tag/attribute validation
  • SVG-aware: Correct camelCase attribute handling for SVG elements
  • LLM-friendly: Perfect for AI-generated interfaces

Installation

pip install nitro-ui

AI Assistant Integration

Add NitroUI knowledge to your AI coding assistant:

npx skills add nitrosh/nitro-ui

This enables AI assistants like Claude Code to understand NitroUI and generate correct HTML code.

Quick Examples

Dynamic Content

from nitro_ui import *

def render_user_card(user):
    return Div(
        Image(src=user["avatar"], alt=user["name"]),
        H3(user["name"]),
        Paragraph(user["bio"]),
        Anchor("View Profile", href=f"/users/{user['id']}"),
        cls="user-card"
    )

users = [
    {"id": 1, "name": "Alice", "bio": "Backend engineer", "avatar": "/avatars/alice.jpg"},
    {"id": 2, "name": "Bob", "bio": "Frontend developer", "avatar": "/avatars/bob.jpg"},
]

grid = Div(*[render_user_card(u) for u in users], cls="user-grid")

Method Chaining

from nitro_ui import *

card = (Div()
    .add_attribute("id", "hero")
    .add_styles({"background": "linear-gradient(135deg, #667eea 0%, #764ba2 100%)", "padding": "4rem"})
    .append(H1("Ship faster with NitroUI"))
    .append(Paragraph("Stop fighting with templates. Start building.")))

Reusable Components

from nitro_ui import *

class Card(Component):
    tag = "div"
    class_name = "card"

    def template(self, title: str):
        return [
            H3(title, cls="card-title"),
            Slot()  # children go here
        ]

class Alert(Component):
    tag = "div"
    class_name = "alert"

    def template(self, message: str, variant: str = "info"):
        self.add_attribute("class", f"alert-{variant}")
        self.add_attribute("role", "alert")
        return [Paragraph(message), Slot()]

# Usage
page = Div(
    Alert("Your changes have been saved.", variant="success"),
    Card("Statistics",
        Paragraph("Total users: 1,234"),
        Paragraph("Active today: 89")
    )
)

Components support named slots for complex layouts:

class Modal(Component):
    tag = "div"
    class_name = "modal"

    def template(self, title: str):
        return [
            Div(H2(title), Slot("actions"), cls="modal-header"),
            Div(Slot(), cls="modal-body"),
            Div(Slot("footer"), cls="modal-footer")
        ]

# Named slots via kwargs
Modal("Confirm Delete",
    Paragraph("Are you sure?"),
    actions=Button("×", cls="close"),
    footer=[Button("Cancel"), Button("Delete", cls="danger")]
)

External Stylesheets with Themes

from nitro_ui import *
from nitro_ui.styles import CSSStyle, StyleSheet, Theme

# Use a preset theme
theme = Theme.modern()
stylesheet = StyleSheet(theme=theme)

# Register component styles
btn = stylesheet.register("btn", CSSStyle(
    background_color="var(--color-primary)",
    color="var(--color-white)",
    padding="var(--spacing-sm) var(--spacing-md)",
    border_radius="6px",
    border="none",
    cursor="pointer",
    _hover=CSSStyle(background_color="var(--color-primary-dark)")
))

# Use in your HTML
page = HTML(
    Head(
        Title("Styled Page"),
        Style(stylesheet.render())
    ),
    Body(
        Button("Click Me", cls=btn)
    )
)

Framework Integration

FastAPI

from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from nitro_ui import *

app = FastAPI()

@app.get("/", response_class=HTMLResponse)
async def home():
    return HTML(
        Head(Title("FastAPI + NitroUI")),
        Body(H1("Hello from FastAPI"))
    ).render()

Flask

from flask import Flask
from nitro_ui import *

app = Flask(__name__)

@app.route("/")
def home():
    return HTML(
        Head(Title("Flask + NitroUI")),
        Body(H1("Hello from Flask"))
    ).render()

Django

from django.http import HttpResponse
from nitro_ui import *

def home(request):
    return HttpResponse(HTML(
        Head(Title("Django + NitroUI")),
        Body(H1("Hello from Django"))
    ).render())

Core Features

Pretty Printing

# Compact output (default) - ideal for production
page.render()

# Indented output - ideal for debugging
page.render(pretty=True)

JSON Serialization

Perfect for drag-and-drop builders, undo/redo, or API communication:

from nitro_ui import *
from nitro_ui.core.element import HTMLElement

# Serialize
json_data = page.to_json(indent=2)

# Deserialize
restored = HTMLElement.from_json(json_data)

HTML Parsing

Import existing HTML into NitroUI for manipulation:

from nitro_ui import from_html

element = from_html('<div class="card"><h1>Hello</h1></div>')
element.append(Paragraph("Added with NitroUI"))

Fragments

Group elements without a wrapper tag:

from nitro_ui import *

def table_rows(items):
    return Fragment(*[
        TableRow(TableDataCell(item["name"]), TableDataCell(item["price"]))
        for item in items
    ])

Form Builder

Generate HTML5 forms with validation using the Field class:

from nitro_ui import *

form = Form(
    Field.email("email", label="Email", required=True),
    Field.password("password", label="Password", min_length=8),
    Field.select("country", ["USA", "Canada", "Mexico"], label="Country"),
    Field.checkbox("terms", label="I agree to the Terms", required=True),
    Button("Sign Up", type="submit"),
    action="/register"
)

Field types: text, email, password, url, tel, search, textarea, number, range, date, time, datetime_local, select, checkbox, radio, file, hidden, color. See SKILL.md for full API.

HTMX Integration

Build interactive UIs without JavaScript. NitroUI converts hx_* kwargs to hx-* attributes automatically:

from nitro_ui import *

# Live search
Input(
    type="text",
    hx_get="/search",
    hx_trigger="keyup changed delay:300ms",
    hx_target="#results"
)

# Delete with confirmation
Button(
    "Delete",
    hx_delete="/items/1",
    hx_confirm="Are you sure?",
    hx_swap="outerHTML"
)

# Load more
Button("Load More", hx_get="/items?page=2", hx_target="#list", hx_swap="beforeend")

All HTMX attributes are supported: hx_get, hx_post, hx_put, hx_delete, hx_target, hx_swap, hx_trigger, hx_confirm, hx_indicator, hx_boost, and more. See SKILL.md for the complete reference.

Raw HTML Partials

Embed raw HTML for trusted content like analytics tags:

from nitro_ui import Head, Meta, Title, Partial

Head(
    Meta(charset="utf-8"),
    Partial("""
        <!-- Google Analytics -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=GA_ID"></script>
        <script>
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', 'GA_ID');
        </script>
    """),
    Title("My Page")
)

# Or load from a file (lazy-loaded at render time)
Partial(file="partials/analytics.html")

Warning: Partial bypasses HTML escaping. Only use with trusted content.

CSS Style Helpers

div = Div("Content")
div.add_style("color", "blue")
div.add_styles({"padding": "20px", "margin": "10px"})
div.remove_style("margin")
color = div.get_style("color")  # "blue"

Available Elements

Import all elements with from nitro_ui import *:

ModuleElements
nitro_ui.tags.htmlHTML, Head, Body, Title, Meta, Link, Script, Style, Base, Noscript, IFrame, Template, Svg, Math
nitro_ui.tags.layoutDiv, Section, Article, Header, Nav, Footer, Main, Aside, Details, Summary, Dialog, Address, Hgroup, Search, Menu
nitro_ui.tags.textH1-H6, Paragraph, Span, Strong, Em, Bold, Italic, Anchor (alias: Href), Code, Pre, Blockquote, Br, Wbr, Bdi, Bdo, Ruby, Rt, Rp, Data, and more
nitro_ui.tags.formForm, Input, Button, Select, Option, Textarea, Label, Fieldset, Legend, Optgroup, Output, Progress, Meter, Datalist
nitro_ui.tags.listsUnorderedList, OrderedList, ListItem, DescriptionList, DescriptionTerm, DescriptionDetails
nitro_ui.tags.mediaImage, Video, Audio, Source, Track, Picture, Figure, Figcaption, Canvas, Embed, Object, Param, Map, Area
nitro_ui.tags.tableTable, TableRow, TableHeader, TableBody, TableFooter, TableHeaderCell, TableDataCell, Caption, Col, Colgroup

Element API

Manipulation - append(*children) / prepend(*children) - Add children - clear() - Remove all children - clone() - Deep copy element - find_by_attribute(attr, value) - Find child by attribute

Attributes - add_attribute(key, value) / add_attributes(list) - get_attribute(key) / has_attribute(key) - remove_attribute(key) - HTML5 boolean attributes (disabled, checked, required, etc.) render correctly: True renders as a bare attribute, False omits it, None omits it - SVG camelCase attributes are supported via snake_case kwargs: view_box renders as viewBox, preserve_aspect_ratio as preserveAspectRatio, etc.

Styles - add_style(prop, value) / add_styles(dict) - get_style(prop) / remove_style(prop)

Output - render(pretty=False) - Generate HTML string - to_json() / from_json() - JSON serialization - to_dict() / from_dict() - Dictionary conversion

All manipulation methods return self for chaining.

For AI/LLM Integration

NitroUI is designed to work seamlessly with AI code generation. See SKILL.md for a complete technical reference including method signatures, all tags, and common patterns.

Development

# Setup
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Run tests
pytest

# Format
black src/ tests/

Ecosystem

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

API Reference

Auto-generated from the installed package's public API. Signatures and docstrings come directly from the source.

Components

Component#

Component(*args, **kwargs)

Base class for building reusable components with declarative templates.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

template(self) -> List[Any]

Override to define this component's structure.

text()

Text content of this element (already-joined, unescaped source).

Element base

HTMLElement#

HTMLElement(*children: Union[ForwardRef('HTMLElement'), str, List[Any]], tag: str, self_closing: bool = False, **attributes: str)

Foundation class for every HTML element in NitroUI.

37 methods
add_attribute(self, key: str, value: str) -> 'HTMLElement'

Set a single HTML attribute on this element.

add_attributes(self, attributes: List[Tuple[str, str]]) -> 'HTMLElement'

Set multiple HTML attributes in one call.

add_style(self, key: str, value: str) -> 'HTMLElement'

Add a single inline CSS declaration to this element.

add_styles(self, styles: dict) -> 'HTMLElement'

Merge a dict of inline CSS declarations into this element.

append(self, *children: Union[ForwardRef('HTMLElement'), str, List[Any]]) -> 'HTMLElement'

Add children to the end of this element.

attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

clear(self) -> 'HTMLElement'

Remove all children from this element.

clone(self) -> 'HTMLElement'

Return a deep copy of this element and its entire subtree.

count_children(self) -> int

Return the number of direct children (not including text content).

filter(self, condition: Callable[[Any], bool], recursive: bool = False, max_depth: int = 1000, _current_depth: int = 0) -> Iterator[ForwardRef('HTMLElement')]

Yield children (and optionally descendants) matching a predicate.

find_by_attribute(self, attr_name: str, attr_value: Any, max_depth: int = 1000) -> Optional[ForwardRef('HTMLElement')]

Return the first descendant (or self) whose attribute matches.

first(self) -> Optional[ForwardRef('HTMLElement')]

Return the first child, or ``None`` if this element has none.

from_dict(data: dict, _depth: int = 0, max_depth: int = 1000) -> 'HTMLElement'

Reconstruct an element tree from a ``to_dict()`` result.

from_json(json_str: str) -> 'HTMLElement'

Reconstruct an element tree from a ``to_json()`` result.

generate_id(self) -> None

Assign an auto-generated ``id`` attribute if one is not already set.

get_attribute(self, key: str) -> Optional[str]

Return the value of a named attribute, or ``None`` if absent.

get_attributes(self, *keys: str) -> dict

Return a copy of attributes, optionally restricted to given keys.

get_style(self, key: str) -> Optional[str]

Return the inline CSS value for a property, or ``None`` if unset.

has_attribute(self, key: str) -> bool

Return ``True`` if the given attribute is set on this element.

last(self) -> Optional[ForwardRef('HTMLElement')]

Return the last child, or ``None`` if this element has none.

on_after_render(self) -> None

Hook called immediately after this element finishes rendering.

on_before_render(self) -> None

Hook called immediately before this element renders itself.

on_load(self) -> None

Hook called at the end of ``__init__``. Override for custom setup.

on_unload(self) -> None

Hook called from ``__del__``. Do not rely on this for cleanup.

pop(self, index: int = 0) -> 'HTMLElement'

Remove and return a child by position.

prepend(self, *children: Union[ForwardRef('HTMLElement'), str, List[Any]]) -> 'HTMLElement'

Insert children at the front of this element.

remove_all(self, condition: Callable[[Any], bool]) -> 'HTMLElement'

Remove every direct child matching a predicate.

remove_attribute(self, key: str) -> 'HTMLElement'

Remove an attribute by key. Missing keys are silently ignored.

remove_style(self, key: str) -> 'HTMLElement'

Remove an inline CSS declaration by property name.

render(self, pretty: bool = False, _indent: int = 0, max_depth: int = 1000) -> str

Serialize this element and its subtree to an HTML string.

replace_child(self, old_index: int, new_child: 'HTMLElement') -> None

Swap a child at the given index with a new element.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

to_dict(self, _depth: int = 0, max_depth: int = 1000) -> dict

Serialize this element and its subtree to a plain dict.

to_json(self, indent: Optional[int] = None) -> str

Serialize this element and its subtree to a JSON string.

Fragments & slots

Fragment#

Fragment(*children: Union[ForwardRef('HTMLElement'), str, List[Any]], **attributes: str)

A container that renders only its children without wrapping tags.

6 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

render(self, pretty: bool = False, _indent: int = 0, max_depth: int = 1000) -> str

Renders only the children without the fragment wrapper.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Slot#

Slot(name: str = None, default: Union[ForwardRef('HTMLElement'), List[Any], NoneType] = None)

Marker for where content should be inserted in a Component template.

6 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

render(self, pretty: bool = False, _indent: int = 0, max_depth: int = 1000) -> str

Return an empty string - ``Component`` replaces slots before render.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Raw HTML partials

Partial#

Partial(html: str = None, *, file: str = None)

Embeds raw HTML directly without escaping.

10 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

from_dict(data: dict) -> 'Partial'

Reconstruct a ``Partial`` from a ``to_dict()`` result.

from_json(json_str: str) -> 'Partial'

Reconstruct a ``Partial`` from a ``to_json()`` result.

render(self, pretty: bool = False, _indent: int = 0, max_depth: int = 1000) -> str

Renders the raw HTML content.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

to_dict(self) -> dict

Return a dict with ``type="partial"`` plus the source marker.

to_json(self, indent: int = None) -> str

Serialize this Partial to a JSON string.

HTML parser

from_html#

from_html(html_string: str, fragment: bool = False) -> Union[nitro_ui.core.element.HTMLElement, List[nitro_ui.core.element.HTMLElement], NoneType]

Parse an HTML string into a NitroUI element tree.

Form builder

Field#

Field()

Factory of static methods that emit common HTML5 form inputs.

18 methods
checkbox(name: str, label: Optional[str] = None, checked: bool = False, value: str = 'on', wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[str] = None, required: bool = False, **attrs) -> nitro_ui.core.elem...

Build an ``<input type="checkbox">``, with the label wrapping the input.

color(name: str, label: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[str] = None, **attrs) -> nitro_ui.core.element.HTMLElement

Build an ``<input type="color">`` color picker.

date(name: str, label: Optional[str] = None, required: bool = False, min: Optional[str] = None, max: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[st...

Build an ``<input type="date">`` picker constrained to ``YYYY-MM-DD`` dates.

datetime_local(name: str, label: Optional[str] = None, required: bool = False, min: Optional[str] = None, max: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[st...

Build an ``<input type="datetime-local">`` picker for local datetimes.

email(name: str, label: Optional[str] = None, required: bool = False, placeholder: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[str] = None, **attrs)...

Build an ``<input type="email">`` with browser-side format validation.

file(name: str, label: Optional[str] = None, required: bool = False, accept: Optional[str] = None, multiple: bool = False, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[str] = None, **attrs) -> nitro_...

Build an ``<input type="file">`` for attaching files from the client.

hidden(name: str, value: str, **attrs) -> nitro_ui.core.element.HTMLElement

Build an ``<input type="hidden">`` for carrying state through a form.

number(name: str, label: Optional[str] = None, required: bool = False, min: Union[int, float, NoneType] = None, max: Union[int, float, NoneType] = None, step: Union[int, float, str, NoneType] = None, value: Union[int, float...

Build an ``<input type="number">`` for numeric entry.

password(name: str, label: Optional[str] = None, required: bool = False, min_length: Optional[int] = None, max_length: Optional[int] = None, placeholder: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = N...

Build an ``<input type="password">`` with optional length constraints.

radio(name: str, options: List[Union[tuple, Dict[str, Any]]], label: Optional[str] = None, required: bool = False, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, **attrs) -> nitro_ui.cor...

Build a radio-button group wrapped in an accessible ``<fieldset>``.

range(name: str, label: Optional[str] = None, min: Union[int, float] = 0, max: Union[int, float] = 100, step: Union[int, float, str, NoneType] = None, value: Union[int, float, NoneType] = None, wrapper: Union[str, Dict[str...

Build an ``<input type="range">`` slider with a bounded numeric range.

search(name: str, label: Optional[str] = None, required: bool = False, placeholder: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[str] = None, **attrs)...

Build an ``<input type="search">`` with browser-provided clear affordance.

select(name: str, options: List[Union[str, tuple, Dict[str, Any]]], label: Optional[str] = None, required: bool = False, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[str] =...

Build a ``<select>`` dropdown populated from a flexible options list.

tel(name: str, label: Optional[str] = None, required: bool = False, pattern: Optional[str] = None, placeholder: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id:...

Build an ``<input type="tel">`` for phone-number entry.

text(name: str, label: Optional[str] = None, required: bool = False, min_length: Optional[int] = None, max_length: Optional[int] = None, pattern: Optional[str] = None, placeholder: Optional[str] = None, value: Optional[st...

Build a single-line ``<input type="text">`` with validation attrs.

textarea(name: str, label: Optional[str] = None, required: bool = False, rows: Optional[int] = None, cols: Optional[int] = None, min_length: Optional[int] = None, max_length: Optional[int] = None, placeholder: Optional[str] =...

Build a multi-line ``<textarea>`` input.

time(name: str, label: Optional[str] = None, required: bool = False, min: Optional[str] = None, max: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[st...

Build an ``<input type="time">`` picker constrained to ``HH:MM`` times.

url(name: str, label: Optional[str] = None, required: bool = False, placeholder: Optional[str] = None, value: Optional[str] = None, wrapper: Union[str, Dict[str, Any], NoneType] = None, id: Optional[str] = None, **attrs)...

Build an ``<input type="url">`` with browser-side URL validation.

Styling

CSSStyle#

CSSStyle(**kwargs)

Declarative CSS style with pseudo-selector and breakpoint support.

6 methods
from_dict(data: Dict[str, Any]) -> 'CSSStyle'

Reconstruct a ``CSSStyle`` from a ``to_dict()`` result.

has_pseudo_or_breakpoints(self) -> bool

Return ``True`` if this style carries any pseudo-selector or breakpoint.

is_complex(self, threshold: int = 3) -> bool

Return ``True`` when the base declaration count exceeds a threshold.

merge(self, other: 'CSSStyle') -> 'CSSStyle'

Combine another style into a new ``CSSStyle`` without mutating either.

to_dict(self) -> Dict[str, Any]

Serialize this style (including nested pseudo/breakpoint maps) to a dict.

to_inline(self) -> str

Render the base declarations as a single ``style`` attribute value.

StyleSheet#

StyleSheet(theme: Optional[ForwardRef('Theme')] = None)

Registry of named CSS classes that renders to a ``<style>`` block.

13 methods
clear(self) -> None

Drop every registered class and reset the auto-name counter.

count_classes(self) -> int

Return the number of classes currently registered on this sheet.

from_dict(data: Dict, theme: Optional[ForwardRef('Theme')] = None) -> 'StyleSheet'

Reconstruct a ``StyleSheet`` from a ``to_dict()`` result.

get_all_class_names(self) -> List[str]

Return a list of every registered class name, in insertion order.

get_style(self, name: str) -> Optional[nitro_ui.styles.style.CSSStyle]

Return the style registered for a class name, or ``None`` if absent.

has_class(self, name: str) -> bool

Return ``True`` if a style is registered under this class name.

register(self, name: Optional[str] = None, style: Optional[nitro_ui.styles.style.CSSStyle] = None) -> str

Store a style under a class name and return the name for use in HTML.

register_bem(self, block: str, element: Optional[str] = None, modifier: Optional[str] = None, style: Optional[nitro_ui.styles.style.CSSStyle] = None) -> str

Register a style with a BEM-formatted class name.

render(self, pretty: bool = True) -> str

Emit the full CSS text for every registered class.

set_breakpoint(self, name: str, value: str) -> None

Override the ``min-width`` value used for a named breakpoint.

to_dict(self) -> Dict

Serialize registered classes and breakpoint overrides to a dict.

to_style_tag(self, pretty: bool = True) -> str

Return the rendered CSS wrapped in a ready-to-drop ``<style>`` tag.

unregister(self, name: str) -> bool

Remove a registered class and return whether it existed.

Theme#

Theme(name: str = 'Default', colors: Optional[Dict[str, str]] = None, typography: Optional[Dict[str, Any]] = None, spacing: Optional[Dict[str, str]] = None, components: Optional[Dict[str, Any]] = None)

Named design tokens plus component style presets.

7 methods
classic() -> 'Theme'

Return the built-in "Classic" preset.

from_dict(data: Dict[str, Any]) -> 'Theme'

Reconstruct a ``Theme`` from a ``to_dict()`` result.

get_component_style(self, component: str, variant: str = 'default') -> Optional[nitro_ui.styles.style.CSSStyle]

Look up a preset ``CSSStyle`` for a component, optionally by variant.

get_css_variables(self) -> Dict[str, str]

Flatten colors, spacing, and typography into CSS custom properties.

minimal() -> 'Theme'

Return the built-in "Minimal" preset.

modern() -> 'Theme'

Return the built-in "Modern" preset.

to_dict(self) -> Dict[str, Any]

Serialize the theme (including nested component styles) to a dict.

HTML elements

Textarea#

Textarea(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Select#

Select(*args, **kwargs)

HTML ``<select>`` dropdown with a convenience option builder.

6 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

with_items(*items, **kwargs) -> 'Select'

Build a ``<select>`` and wrap plain items as ``<option>`` children.

Option#

Option(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Button#

Button(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Fieldset#

Fieldset(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Form#

Form(*args, **kwargs)

HTML ``<form>`` element with a convenience field-appending builder.

6 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

with_fields(*items, **kwargs) -> 'Form'

Build a ``<form>`` from a flat list of fields and text nodes.

Input#

Input(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Label#

Label(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Optgroup#

Optgroup(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Legend#

Legend(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Output#

Output(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Progress#

Progress(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Meter#

Meter(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Datalist#

Datalist(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

HTML#

HTML(*args, **kwargs)

Root ``<html>`` element that also emits ``<!DOCTYPE html>``.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Head#

Head(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Body#

Body(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Title#

Title(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Meta#

Meta(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Link(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Script#

Script(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Style#

Style(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

IFrame#

IFrame(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Base#

Base(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Noscript#

Noscript(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Template#

Template(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Svg#

Svg(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Math#

Math(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Div#

Div(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Section#

Section(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Header#

Header(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Nav#

Nav(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Footer(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

HorizontalRule#

HorizontalRule(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Main#

Main(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Article#

Article(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Aside#

Aside(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Details#

Details(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Summary#

Summary(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Dialog#

Dialog(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Address#

Address(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Hgroup#

Hgroup(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Search(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Menu#

Menu(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

UnorderedList#

UnorderedList(*args, **kwargs)

HTML ``<ul>`` element with a convenience item-wrapping builder.

6 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

with_items(*items, **kwargs) -> 'UnorderedList'

Build a ``<ul>`` and wrap plain items as ``<li>`` children.

OrderedList#

OrderedList(*args, **kwargs)

HTML ``<ol>`` element with a convenience item-wrapping builder.

6 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

with_items(*items, **kwargs) -> 'OrderedList'

Build an ``<ol>`` and wrap plain items as ``<li>`` children.

ListItem#

ListItem(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

DescriptionDetails#

DescriptionDetails(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

DescriptionList#

DescriptionList(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

DescriptionTerm#

DescriptionTerm(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Image#

Image(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Video#

Video(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Audio#

Audio(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Source#

Source(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Picture#

Picture(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Figure#

Figure(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Figcaption#

Figcaption(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Canvas#

Canvas(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Track#

Track(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Embed#

Embed(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Object#

Object(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Param#

Param(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Map#

Map(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Area#

Area(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Table#

Table(*args, **kwargs)

HTML ``<table>`` element with helpers for loading data from files.

7 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

from_csv(file_path: str, encoding: str = 'utf-8') -> 'Table'

Load a CSV file into a ``<table>`` of ``<tr>`` / ``<td>`` rows.

from_json(file_path: str, encoding: str = 'utf-8') -> 'Table'

Load a JSON file (a list of row-lists) into a ``<table>``.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

TableFooter#

TableFooter(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

TableHeaderCell#

TableHeaderCell(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

TableHeader#

TableHeader(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

TableBody#

TableBody(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

TableDataCell#

TableDataCell(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

TableRow#

TableRow(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Caption#

Caption(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Col#

Col(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Colgroup#

Colgroup(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

H1#

H1(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

H2#

H2(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

H3#

H3(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

H4#

H4(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

H5#

H5(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

H6#

H6(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Paragraph#

Paragraph(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Blockquote#

Blockquote(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Pre#

Pre(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Quote#

Quote(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Cite#

Cite(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Em#

Em(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Italic#

Italic(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Span#

Span(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Strong#

Strong(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Abbr#

Abbr(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Anchor#

Anchor(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Href#

Href(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Small#

Small(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Superscript#

Superscript(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Subscript#

Subscript(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Time#

Time(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Code#

Code(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Bold#

Bold(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Del#

Del(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Ins#

Ins(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Strikethrough#

Strikethrough(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Underline#

Underline(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Kbd#

Kbd(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Samp#

Samp(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Var#

Var(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Mark#

Mark(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Dfn#

Dfn(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Br#

Br(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Wbr#

Wbr(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Bdi#

Bdi(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Bdo#

Bdo(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Ruby#

Ruby(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Rt#

Rt(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Rp#

Rp(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).

Data#

Data(*args, **kwargs)

HTML element class for a single fixed tag.

5 methods
attributes()

Live dict of attributes. Mutation invalidates the styles cache on assign.

children()

A shallow copy of the list of child elements.

self_closing()

Whether this element renders as a void/self-closing tag.

tag()

The HTML tag name (e.g. ``"div"``, ``"span"``).

text()

Text content of this element (already-joined, unescaped source).