Skip to main content

Add htmx + DaisyUI based UI to FastAPI with pure Python

Project description

logo

PyPI version Python 3.11+ License: MIT

Add beautiful UI to FastAPI with pure Python. No JavaScript, no templates, no frontend build step.

Quick Start

pip install kokage-ui
from fastapi import FastAPI
from kokage_ui import KokageUI, Page, Card, H1, P, DaisyButton

app = FastAPI()
ui = KokageUI(app)

@ui.page("/")
def home():
    return Page(
        Card(
            H1("Hello, World!"),
            P("Built with FastAPI + htmx + DaisyUI. Pure Python."),
            actions=[DaisyButton("Get Started", color="primary")],
            title="Welcome to kokage-ui",
        ),
        title="Hello App",
    )
uvicorn hello:app --reload

Features

  • 50+ HTML ElementsDiv, H1, Form, Input, etc. as Python classes
  • 25+ DaisyUI ComponentsCard, Hero, NavBar, Modal, Tabs, Accordion, Toast, Layout, and more
  • Pydantic → UI — Auto-generate forms, tables, detail views from BaseModel
  • One-line CRUDui.crud("/users", model=User, storage=storage)
  • DataGrid — Sortable, filterable table with pagination, bulk actions, CSV export
  • Admin Dashboard — Django-like admin panel: AdminSite(app).register(User, storage=s)
  • Auth UILoginForm, RegisterForm, UserMenu, RoleGuard, @protected decorator
  • Theme SystemDarkModeToggle and ThemeSwitcher with localStorage persistence
  • Real-time Notifications — SSE-based push notifications via Notifier + NotificationStream
  • SQLModel Storage — Async database persistence with SQLModelStorage
  • htmx PatternsAutoRefresh, SearchFilter, InfiniteScroll, SSEStream, ConfirmDelete
  • Charts & MarkdownChart (Chart.js), CodeBlock (Highlight.js), Markdown
  • Multi-step FormsMultiStepForm with step validation
  • CLI Scaffoldingkokage-ui init myapp to generate project templates
  • XSS Protection — Output escaped via markupsafe by default

CLI

uvx kokage-ui init myapp            # Create new project
uvx kokage-ui init myapp --crud     # Create with CRUD template
uvx kokage-ui add page dashboard    # Add a new page
uvx kokage-ui add crud Product      # Add CRUD model

Examples

Example Description Run
hello.py Minimal app uvicorn examples.hello:app
todo.py CRUD todo app uvicorn examples.todo:app
dashboard.py Full dashboard uvicorn examples.dashboard:app

Documentation

For detailed guides, component reference, and API docs, see the full documentation.

License

MIT

Project details


Download files

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

Source Distribution

kokage_ui-0.2.0.tar.gz (226.5 kB view details)

Uploaded Source

Built Distribution

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

kokage_ui-0.2.0-py3-none-any.whl (82.7 kB view details)

Uploaded Python 3

File details

Details for the file kokage_ui-0.2.0.tar.gz.

File metadata

  • Download URL: kokage_ui-0.2.0.tar.gz
  • Upload date:
  • Size: 226.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for kokage_ui-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bb504e7a59eb030ff8c5585f8fcf885bb18eb814451be4275499474f008a55bd
MD5 83bfc137f71e1756e32dc6467cd569e6
BLAKE2b-256 a56b71b4010a329cf4db999e0b84013084daf42318a4b567777b7f5e615be7e9

See more details on using hashes here.

File details

Details for the file kokage_ui-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: kokage_ui-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 82.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for kokage_ui-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25eb71f8055591c44a91bec8433b89571369903ab26de9a31f5cc100e3290e06
MD5 68d9336057bb3694c34bfd333edcb0a5
BLAKE2b-256 ce9550045ae513cbd79a1c2d1d5847742cd0c5bac1d4fb105cd33b76397ab520

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page