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).

Download files

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

Source Distribution

b9ui-0.1.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

b9ui-0.1.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file b9ui-0.1.0.tar.gz.

File metadata

  • Download URL: b9ui-0.1.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.4.0

File hashes

Hashes for b9ui-0.1.0.tar.gz
Algorithm Hash digest
SHA256 addf9da85f82cf51c597f6ab5bf156c7f613f951b16617e0c45c3772af1fcef5
MD5 e8cb7c2524e658bb7dcdd4c4f16cf94e
BLAKE2b-256 facfa3e33b35528e308ef0ccdbad5dde62a5aec5f5acff78304fb815bd8263fb

See more details on using hashes here.

File details

Details for the file b9ui-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: b9ui-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.4.0

File hashes

Hashes for b9ui-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27a7db26826ff49f373001c327795a1c9101a167246ce9eb17823baf8468f8f6
MD5 f22ae8b4de48ffa221a5b4ed96d2faf0
BLAKE2b-256 fbbcc463842b51045cdb2126c8d21af0dca61bbc87252b1f41a5e8bb6c32ea8d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.0 This release

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