Add htmx + DaisyUI based UI to FastAPI with pure Python
Project description
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 Elements —
Div,H1,Form,Input, etc. as Python classes - 25+ DaisyUI Components —
Card,Hero,NavBar,Modal,Tabs,Accordion,Toast,Layout, and more - Pydantic → UI — Auto-generate forms, tables, detail views from
BaseModel - One-line CRUD —
ui.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 UI —
LoginForm,RegisterForm,UserMenu,RoleGuard,@protecteddecorator - Theme System —
DarkModeToggleandThemeSwitcherwith localStorage persistence - Real-time Notifications — SSE-based push notifications via
Notifier+NotificationStream - SQLModel Storage — Async database persistence with
SQLModelStorage - htmx Patterns —
AutoRefresh,SearchFilter,InfiniteScroll,SSEStream,ConfirmDelete - Charts & Markdown —
Chart(Chart.js),CodeBlock(Highlight.js),Markdown - Multi-step Forms —
MultiStepFormwith step validation - CLI Scaffolding —
kokage-ui init myappto generate project templates - XSS Protection — Output escaped via
markupsafeby 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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
kokage_ui-0.2.0-py3-none-any.whl
(82.7 kB
view details)
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb504e7a59eb030ff8c5585f8fcf885bb18eb814451be4275499474f008a55bd
|
|
| MD5 |
83bfc137f71e1756e32dc6467cd569e6
|
|
| BLAKE2b-256 |
a56b71b4010a329cf4db999e0b84013084daf42318a4b567777b7f5e615be7e9
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25eb71f8055591c44a91bec8433b89571369903ab26de9a31f5cc100e3290e06
|
|
| MD5 |
68d9336057bb3694c34bfd333edcb0a5
|
|
| BLAKE2b-256 |
ce9550045ae513cbd79a1c2d1d5847742cd0c5bac1d4fb105cd33b76397ab520
|