Module

ext.chirp_ui

chirp-ui integration — register static files and filters for chirp-ui components.

Requires: pip install chirp-ui

Usage::

from chirp import App
from chirp.ext.chirp_ui import use_chirp_ui

app = App(AppConfig(template_dir="templates"))
use_chirp_ui(app)  # Registers static files, filters (bem, field_errors, html_attrs), and middleware
app.run()

Classes

_ChirpUIAppThemeInject 2
Inject ChirpUI's token-only app theme after the base stylesheet.

Inject ChirpUI's token-only app theme after the base stylesheet.

Methods

Internal Methods 2
__init__ 1
def __init__(self, prefix: str) -> None
Parameters
Name Type Description
prefix
__call__ 2 AnyResponse
async
async def __call__(self, request: Request, next: Next) -> AnyResponse
Parameters
Name Type Description
request
next
Returns
AnyResponse

Functions

use_chirp_ui 3 None
Register chirp-ui static files (CSS, themes) and filters with the app. Call af…
def use_chirp_ui(app: App, prefix: str = '/static', strict: bool | Literal['auto'] | None = None) -> None

Register chirp-ui static files (CSS, themes) and filters with the app.

Call after App creation. Serves chirpui.css, chirpui-alpine.js, themes/, chirpui-transitions.css from the chirp-ui package. Automatically registers chirp-ui filters (bem, field_errors, html_attrs, validate_variant) so components render correctly. It also upgrades chirp-ui's route_link_attrs global to use Chirp's route-aware swap_attrs resolution for supported internal links.

Alpine.js is auto-enabled (chirp-ui components require it). Chirp is the single authority for Alpine injection — theapp_shell_layout.htmldoes not include its own Alpine scripts.

strictcontrols chirp-ui variant validation (invalid variants escalate from warning toValueError). None(default) mirrors app.config.debug. True/Falseset the mode explicitly. "auto" delegates to chirp-ui's CHIRP_UI_DEVenv var so dev hosts opt in without code changes.

Raises ImportError if chirp-ui is not installed.

Parameters
Name Type Description
app App
prefix str Default:'/static'
strict bool | Literal['auto'] | None Default:None
_discover_chirpui_components 0 frozenset[str] | None
Return the set of available chirp-ui component template filenames. Returns ``N…
def _discover_chirpui_components() -> frozenset[str] | None

Return the set of available chirp-ui component template filenames.

ReturnsNoneif the chirp-ui templates directory cannot be found (e.g. editable install without the expected layout).

Returns
frozenset[str] | None
check_chirpui_imports 2 None
Verify that ``{% from "chirpui/..." %}`` imports reference real components. Ca…
def check_chirpui_imports(snapshot: ContractCheckSnapshot, result: CheckResult) -> None

Verify that{% from "chirpui/..." %}imports reference real components.

Catches typos like{% from "chirpui/cardd.html" import card %}at startup instead of letting them surface as runtimeTemplateNotFound errors.

Parameters
Name Type Description
snapshot ContractCheckSnapshot
result CheckResult
check_design_system_surface 2 None
Report design system surface and flag descriptor/template mismatches. Compares…
def check_design_system_surface(snapshot: ContractCheckSnapshot, result: CheckResult) -> None

Report design system surface and flag descriptor/template mismatches.

ComparesCOMPONENTSagainst the actual template files on disk. Components with a declaredtemplatethat does not exist on disk are flagged as errors. Templates that exist but have no descriptor are flagged as informational notes (not all templates need descriptors immediately).

Parameters
Name Type Description
snapshot ContractCheckSnapshot
result CheckResult