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

Download files

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

Source Distribution

hypermedia-6.0.2.tar.gz (133.4 kB view details)

Uploaded Source

Built Distribution

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

hypermedia-6.0.2-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file hypermedia-6.0.2.tar.gz.

File metadata

  • Download URL: hypermedia-6.0.2.tar.gz
  • Upload date:
  • Size: 133.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for hypermedia-6.0.2.tar.gz
Algorithm Hash digest
SHA256 909cb9d297a2b5350db51fd8e35556c50743f061c3c98b7482eade5bbc711d3f
MD5 f5c61102ff7ee7d2726068ba6307edcf
BLAKE2b-256 616492c20bb951dc6d6eea1e29edc953cd37fb9f429a06ec3ece0978656df738

See more details on using hashes here.

File details

Details for the file hypermedia-6.0.2-py3-none-any.whl.

File metadata

  • Download URL: hypermedia-6.0.2-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for hypermedia-6.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aa42aea34d4ee8ada7e9346535756b0746c7c1f4e78cc4c3e142c679b0081f46
MD5 931428474447869b6b9970c239fbadf2
BLAKE2b-256 73195e3d0fdb5f68f908d9a6d8e03b15931ba229fce6b4c8ed96ebe6d5891d7f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

6.0.2 This release

2 files

6.0.1

2 files

6.0.0

2 files

5.4.0

2 files

5.3.4

2 files

5.3.3

2 files

5.3.2

2 files

5.3.1

2 files

5.3.0

2 files

5.2.0

2 files

5.1.0

2 files

5.0.0

2 files

4.1.0

2 files

4.0.0

2 files

3.0.0

2 files

2.2.0

2 files

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

1.0.0

2 files

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