lexigram-ui
Skill1 starsChanged 3 months agoMITView on GitHub
Use when building server-rendered HTML components, HTMX fragments, layouts, or configuring the UI module in a Lexigram application
In this repository17 other files it gives its agents.
- ai-subsystem-quickstartSkill
- auth-and-securitySkill
- caching-patternsSkill
- cli-code-generationSkill
- cli-config-and-inspectSkill
- cli-database-operationsSkill
- cli-project-scaffoldingSkill
- configuration-managementSkill
- creating-providers-and-modulesSkill
- database-repository-patternSkill
- events-and-messagingSkill
- multimedia-generationSkill
- real-time-webSkill
- resilience-patternsSkill
- testing-with-lexigramSkill
- using-result-and-error-codesSkill
- web-controllers-and-routingSkill
The file
Files
Lexigram UI
Overview
Lexigram-ui (experimental, at experimental/apps/lexigram-ui) provides htpy-backed component rendering, HTMX integration, layouts, atoms/molecules/organisms, and theming. Components subclass Component and implement render(); elements are built with el().
Component Pattern
from lexigram.ui import component
from lexigram.ui.core.base import Component, el, render_to_string
class StatCard(Component):
def __init__(self, label: str, value: str):
super().__init__()
self.label = label
self.value = value
def render(self):
return el("div", {"class": "stat-card"},
el("span", {"class": "stat-label"}, self.label),
el("span", {"class": "stat-value"}, self.value),
)
html = render_to_string(StatCard("Users", "1,204"))el(tag, *children, **attrs) builds an element (htpy when installed, local Element fallback); plain-string children are auto-escaped, wrap trusted HTML in raw(...). Component supports Streamlit-style with blocks, as_child delegation, an on_mount hook, and fluent .add(...).
The @component(name=None, *, cacheable=False) decorator only attaches __component_name__ metadata for DI discovery by UIProvider — it does not register anything itself.
Module Registration
from lexigram.di.module import Module, module
from lexigram.ui import UIModule
from lexigram.ui.config import UIConfig
@module(imports=[UIModule.configure(UIConfig(default_theme="default"))])
class AppModule(Module): ...UIModule.configure(config) exports RenderableProtocol; the provider binds UIConfig, MetricsCollector, ResponseOptimizer, and RenderCache singletons. UIModule.stub() gives a no-op for tests.
Config ([ui] section)
ui:
default_theme: default # CSS theme name
theme: light # active theme
auto_escape: true
htmx_version: 2.0.4 # HTMX CDN version
debug_components: false # data-component markers (warns in production)
enable_sse: falseEnv prefix LEX_UI__.
Static Files
Static serving comes from lexigram-web's middleware (constructor takes ASGI app first — use partial/wrapper when adding via middleware list):
from lexigram.web.middleware.static import StaticFilesMiddleware
StaticFilesMiddleware(app, directory="static", prefix="/static")
# html=True enables index.html resolution; cache_max_age sets Cache-ControlCommon Mistakes
- Expecting
@component(...)to register globally — registration happens throughUIProviderdiscovery - Building HTML with f-strings — use
el(); plain strings are escaped,raw()is the explicit opt-out - Forgetting to call
super().__init__()inComponent.__init__— breaks context-stack andon_mount - Enabling
debug_componentsin production — emits debug comments on every fragment
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

