Skip to main content

Hypermedia

Hypermedia is a pure python library for working with HTML. Hypermedia's killer feature is that it is composable through a slot concept. Because of that, it works great with </> htmx where you need to respond with both partials and full page html.

Hypermedia is made to work with FastAPI and </> htmx, but can be used by anything to create HTML.


Python Version from PEP 621 TOML


Documentation Stable | Source Code | Task Tracker

Features

  • Build HTML with python classes
  • Composable templates through a slot system
  • Seamless integration with </> htmx
  • Fully typed and Autocompletion for html/htmx attributes and styles
  • Opinionated simple decorator for FastAPI
  • Unlike other template engines like Jinja2 we have full typing since we never leave python land.

The Basics

All html tags can be imported directly like:

from hypermedia import Html, Body, Div, A

Tags are nested by adding children in the constructor:

from hypermedia import Html, Body, Div

Html(Body(Div(), Div()))

Add text to your tag:

from hypermedia import Div

Div("Hello world!")

use .dump() to dump your code to html.

from hypermedia import Bold, Div

Div("Hello ", Bold("world!")).dump()

output

<div>Hello <b>world!</b></div>

Composability with slots

from hypermedia import Html, Body, Div, Menu, H1, Div, Ul, Li

base = Html(
    Body(
        Menu(slot="menu"),
        Div(slot="content"),
    ),
)

menu = Ul(Li("home"))
content = Div("Some content")

base.extend("menu", menu)
base.extend("content", content)

base.dump()

output

<html>
    <body>
        <menu>
            <ul><li>home</li></ul>
        </menu>
        <div>
            <div>Some content</div>
        </div>
    </body>
</html>

Documentation

Head over to our documentation

If you are using this for HTMX, then please read the HTMX section of the documentation

Metadata

Release files for hypermedia 6.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hypermedia 6.0.2
File Size Uploaded Provenance
hypermedia-6.0.2.tar.gz 133.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hypermedia 6.0.2
File Interpreter ABI Platform
hypermedia-6.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 161.9 kB

Release files / hypermedia-6.0.2.tar.gz

Download URL hypermedia-6.0.2.tar.gz
Size 133.4 kB
Tags Source
SHA-256 checksum
How to use checksums
909cb9d297a2b5350db51fd8e35556c50743f061c3c98b7482eade5bbc711d3f
BLAKE2b-256 checksum
How to use checksums
616492c20bb951dc6d6eea1e29edc953cd37fb9f429a06ec3ece0978656df738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / hypermedia-6.0.2-py3-none-any.whl

Download URL hypermedia-6.0.2-py3-none-any.whl
Size 28.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa42aea34d4ee8ada7e9346535756b0746c7c1f4e78cc4c3e142c679b0081f46
BLAKE2b-256 checksum
How to use checksums
73195e3d0fdb5f68f908d9a6d8e03b15931ba229fce6b4c8ed96ebe6d5891d7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for hypermedia 6.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page