Skip to main content

b9ui is a lightweight framework for building HTML pages with a component approach similar to Next.js. It is designed so that developers need to write almost no JavaScript to create dynamic web services.

[!]

The framework is in a very early development/testing phase. There are currently a lot of half-functioning features. We welcome your contributions to help progress!

Requirements

python = "^3.12" ludic = "^0.4.0"

Installation


pip install “b9ui”

Similar to Starlette, you will also want to set up an ASGI server:


pip install uvicorn

Full Example

app/layout.py:

from typing import override
from b9ui.attrs import NoAttrs 
from b9ui.components import Component
from b9ui.html import html, head, body, div, link, script, title
from b9ui.types import AnyChildren


class Layout(Component[AnyChildren, NoAttrs]):
    @override
    def render(self) -> html:
        return html(
            head(
                title("Hello, World! App"),
                link(href="/static/css/default.css", rel="stylesheet"),
            ),
            body(
                div(
                    div(
                        div(
                            div(
                                div(*self.children,
                                    class_="pb-24 flex flex-col justify-between w-full"
                                ),                                
                                class_="w-full flex justify-center"
                            ),
                            class_="py-16 overflow-auto flex flex-row"
                        ),                                                
                        class_="app text-stone-700 dark:text-gray-100 bg-white dark:bg-stone-900 min-h-screen"
                    ),
                    class_="display: contents"
                ),                
                script(src="https://unpkg.com/htmx.org@1.9.10"),
                script(src="https://unpkg.com/hyperscript.org@0.9.12"),                
                script(src="https://cdn.tailwindcss.com"),
                class_="min-h-screen bg-background font-sans antialiased __className_aaf875",
            ),
            class_="light",
            lang="en", style="color-scheme: light;"
        )

app/page.py:

from b9ui.components import Blank
from b9ui.html import div, p


async def index() -> Blank:
    return Blank(
        div(
            p("Hello, World!"),
        ),        
    )

To run the application:

uvicorn b9ui.app:app --reload

More Examples

For more complex usage that includes the full capabilities of the framework, please visit the folder with examples [on GitHub] (https://github.com/b9ui/b9ui/tree/master/examples/).

Contributing

Any contribution to the framework is welcome! Your help will make it a better resource for the community. If you are ready to contribute, read [contribution guidelines] (https://github.com/b9ui/b9ui/tree/master/CONTRIBUTING.md).

Metadata

Release files for b9ui 0.2.0

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

Source distribution (sdist)

Source distribution for b9ui 0.2.0
File Size Uploaded
b9ui-0.2.0.tar.gz 15.3 kB Details

Built distribution (wheel)

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

Total release size: 38.1 kB

Release files / b9ui-0.2.0.tar.gz

Download URL b9ui-0.2.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
664115d442507af21e6102ae94587382243134580c5545c9a22a47c62b4b77dd
BLAKE2b-256 checksum
How to use checksums
8adf0245ba1a64e1f848497301aca1fd0ceef6b1e96e98c79b563fdffb75018f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

Release files / b9ui-0.2.0-py3-none-any.whl

Download URL b9ui-0.2.0-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
385a1189f5e0a61d6a5baaec3925f75d15a42be192c072f38de5bf53be1f6739
BLAKE2b-256 checksum
How to use checksums
e4c8b86af2a5dc6188c444ddafeb790e9b455c6fae5113997e0c3b684c238621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release 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