A fast UI for FastAPI
Pages, tables, forms, navigation and htmx swaps for FastAPI, written as Jinja macros next to your routes.
A FastAPI service that needs a real interface has two usual answers. Write Jinja and hand-roll the CSS, and you own a design system you did not set out to build. Reach for a front-end framework, and you own a second build, a second language and a second thing to deploy.
fjkit is a third answer. The interface is Jinja macros beside your routes, and the stylesheet
was compiled when fjkit was released — so your repository gets no package.json,
and there is nothing to rebuild when you edit a template.
A page the kit rendered
The demo in examples/fjkit-demo. Navigation, dark mode, a filterable table, a form that validates and htmx swaps — and no .css or .js file anywhere in that app.
What the third answer gives you
No build step
No package.json, no node_modules, no watcher. The stylesheet is compiled when fjkit is released, not when your app runs.
One place for every colour
Every colour is a token. Rebranding is one stylesheet, and status colours stay put, so green still means done.
The htmx endpoint is also the JSON API
A route that renders a partial answers htmx with HTML and every other caller with its response model as JSON.
Get started
Install one package, write a handler and a template, run the app.
Requires Python 3.13 or newer.
uv add fjkit
from pathlib import Path
from fastapi import FastAPI
from fjkit import FjkitConfig, mount_fjkit, render
from pydantic import BaseModel
app = FastAPI()
mount_fjkit(app, FjkitConfig(template_dir=Path(__file__).parent / "templates"))
class Overview(BaseModel):
done: int
@app.get("/")
@render("overview.html")
def overview() -> Overview:
return Overview(done=18)
mount_fjkit serves the stylesheet and the vendored JavaScript and builds the
Jinja environment. @render goes below @app.get and passes the
fields of the returned model to the template.
{% extends "ui/shell.html" %}
{% from "ui/layout.html" import page_header, grid %}
{% from "ui/data.html" import stat %}
{% block content %}
{{ page_header("Overview", "How the board is doing") }}
{% call grid(cols=4) %}
{{ stat("Done", done, tone="success", icon_name="check") }}
{% endcall %}
{% endblock %}
uv run fastapi dev app/main.py
Open http://127.0.0.1:8000. The page has a header, a dark-mode toggle and one
stat card. The template has no CSS classes and no colours. Macros take named options such as
tone="success", and the shipped stylesheet covers them.
Add uv run fjkit check app/templates to CI. It fails when a template uses a
class or a colour outside the kit's vocabulary.
Who it is for
A back-end developer who needs a real interface and no front-end toolchain.
You write FastAPI and need navigation, dark mode, a filterable table and a form that validates. If you want React, Vue or Svelte, use them instead. fjkit renders on the server and has no client-side component model.
What it costs
a first page
about twenty lines, as in 01, with no build step
an admin screen
a list, filters, a create form and htmx updates, with no CSS and no JavaScript
What ships in the wheel
One wheel, two runtime dependencies, and nothing for you to compile.
Shipped in the package
templates/ui/
the macros: layout, buttons, data, forms, tables, tabs, navigation, sidebar, feedback, icons, and the document shell
static/dist/fjkit-<pack>.css
the compiled stylesheet, one per style pack. 236 KB raw, 25.2 KB gzip; the build fails above 28 KB. A page loads one.
static/vendor/
htmx and Basecoat's JavaScript, pinned and served out of the package
1,767 icons
Lucide, inlined by name. No icon font, no sprite request, no runtime JS.
Everything you call
FjkitConfig, mount_fjkit
the wiring, once per app
@render
names the template; the handler returns data
Runtime dependencies: FastAPI and Jinja2.
Where to go next
Pick the page by what you are trying to do.
On this site
decide whether to use it at all
Why fjkit — what the alternatives cost, and what this one gives up in exchange
see the shape before I commit to it
Architecture — the five closed decisions as pictures: the package boundary, eject, when the build runs, one partial with two entry points, and the gate loop
build my first real screen
Learn — how the app is wired, how htmx swaps work, form errors, messages, rebranding and fjkit check. Read 01–05 first.
find a component
Components — every macro, live, with the call that produced it
look up a parameter
Cheatsheet — every signature, shell block, template global and htmx attribute on one page
add auth, charts or an admin
Plugins — sign-in, flash messages, charts, an API console and an admin, and how to write your own