Skip to content
GitHub

Configuration

Complete reference of every configuration dataclass in lexigram-ui.


@dataclass
class UIConfig(BaseConfig):
config_section = "ui"

Controls rendering defaults. Read from the [ui] section of application.yaml (or env vars prefixed with LEX_UI__).

FieldTypeDefaultDescription
default_themestr"default"Default CSS theme name passed to shadcn_css()
auto_escapeboolTrueHTML-escape user strings by default
htmx_versionstr"2.0.4"HTMX CDN version
debug_componentsboolFalseRender data-component debug attributes
themestr"light"Active UI theme (light, dark, system)
enable_sseboolFalseEnable Server-Sent Events support
enable_realtimeboolFalseEnable realtime update features

validate_for_environment(env: Environment) -> list[ConfigIssue]

Returns warnings for unsafe config in production (e.g., debug_components=True).

All fields are overridable via LEX_UI__<FIELD>:

Terminal window
LEX_UI__THEME=dark LEX_UI__ENABLE_SSE=true

@dataclass
class DebounceConfig:
delay_ms: int = 300
changed: bool = True

Generates HTMX trigger strings with debounce:

DebounceConfig(delay_ms=500).to_trigger("input")
# → "input changed delay:500ms"

@dataclass
class HTMLDocumentConfig:

Controls the <html> document shell generation.

FieldTypeDefaultDescription
langstr"en"HTML lang attribute
charsetstr"UTF-8"Meta charset
viewportstr"width=device-width, initial-scale=1.0"Viewport meta tag
descriptionstr""Meta description
keywordslist[str][]Meta keywords
authorstr""Meta author
robotsstr""Robots directive (e.g., "noindex, nofollow")
favicon`strNone`None
favicon_typestr"image/x-icon"Favicon MIME type
theme_colorstr"#ffffff"Theme color meta tag
og_titlestr""Open Graph title
og_descriptionstr""Open Graph description
og_imagestr""Open Graph image URL
og_urlstr""Open Graph URL
og_typestr"website"Open Graph type
extra_headstr""Additional raw HTML for <head>

@dataclass
class BaseLayoutConfig(HTMLDocumentConfig):

Extends HTMLDocumentConfig with layout settings.

FieldTypeDefaultDescription
site_namestr"Lexigram Admin"Site name for title suffix
site_logo`strNone`None
site_logo_altstr"Logo"Logo alt text
themestr"light"Active theme
primary_colorstr"#3b82f6"Primary brand color (overridden by CSS variables in ShadCN mode)
accent_colorstr"#8b5cf6"Accent brand color
htmx_enabledboolTrueEnable HTMX
htmx_boostboolTrueEnable HTMX boost
htmx_versionstr"1.9.10"HTMX version
css_fileslist[str][]Additional CSS URLs
js_fileslist[str][]Additional JS URLs
include_alpineboolFalseEnable Alpine.js
alpine_versionstr"3.x.x"Alpine.js version

Note: htmx_version in BaseLayoutConfig defaults to "1.9.10" while UIConfig defaults to "2.0.4". This is intentional — the layout uses v1 for legacy compatibility; the UI config targets v2.


@dataclass
class HeadConfig:

Controls the <head> section rendering via HeadRenderer.

FieldTypeDefaultDescription
css_frameworkstr"tailwind"CSS framework (tailwind, pico, custom)
css_framework_urlstr""Custom CSS framework URL
css_fileslist[str][]Additional CSS file URLs
inline_cssstr""Inline CSS rules
icon_librarystr"lucide"Icon library (lucide, heroicons, feather)
icon_library_urlstrLucide CDNIcon library script URL
font_urlstr""Google Fonts URL
htmx_urlstrHTMX CDNHTMX script URL
include_hyperscriptboolFalseInclude Hyperscript
hyperscript_urlstrHyperscript CDNHyperscript script URL

@dataclass
class FooterConfig:

Controls footer rendering via FooterRenderer.

FieldTypeDefaultDescription
show_copyrightboolTrueShow copyright banner
copyright_holderstr""Copyright holder name
copyright_start_year`intNone`None
show_versionboolTrueShow version number
versionstr""Version string
linkslist[Any][]List of FooterLink objects
stickyboolFalseStick footer to viewport bottom
show_dividerboolTrueShow top divider
custom_leftstr""Custom left section HTML
custom_rightstr""Custom right section HTML

@dataclass
class ToastConfig:

Controls toast container behavior.

FieldTypeDefaultDescription
positionstr"top-right"Position (top-right, top-left, bottom-right, bottom-left)
default_duration_msint5000Default toast duration
max_toastsint5Max visible toasts
stack_directionstr"down"Stack direction (up or down)
listen_for_eventsboolTrueListen for showToast events
event_namestr"showToast"Custom event name
animation_instr"fade-in-right"Entrance animation class
animation_outstr"fade-out-right"Exit animation class

When default_theme="default", the layout generates CSS custom properties via shadcn_css(). These variables are available for use in your own components:

VariableLight DefaultDark Default
--backgroundoklch(1 0 0)oklch(0.145 0 0)
--foregroundoklch(0.145 0 0)oklch(0.925 0 0)
--cardoklch(1 0 0)oklch(0.145 0 0)
--card-foregroundoklch(0.145 0 0)oklch(0.925 0 0)
--popoveroklch(1 0 0)oklch(0.145 0 0)
--popover-foregroundoklch(0.145 0 0)oklch(0.925 0 0)
VariableLightDark
--primaryoklch(0.205 0.042 265)oklch(0.825 0.12 265)
--primary-foregroundoklch(0.985 0 0)oklch(0.205 0.042 265)
--secondaryoklch(0.965 0.016 265)oklch(0.27 0.03 265)
--secondary-foregroundoklch(0.205 0.042 265)oklch(0.985 0 0)
--mutedoklch(0.965 0.016 265)oklch(0.27 0.03 265)
--muted-foregroundoklch(0.535 0.02 265)oklch(0.715 0.015 265)
--accentoklch(0.965 0.016 265)oklch(0.27 0.03 265)
--accent-foregroundoklch(0.205 0.042 265)oklch(0.985 0 0)
--destructiveoklch(0.577 0.245 27)oklch(0.704 0.191 22)
--destructive-foregroundoklch(0.985 0 0)oklch(0.985 0 0)
VariableLightDark
--borderoklch(0.92 0.008 265)oklch(0.27 0.03 265)
--inputoklch(0.92 0.008 265)oklch(0.27 0.03 265)
--ringoklch(0.205 0.042 265)oklch(0.825 0.12 265)
--radius0.5rem0.5rem
VariableLightDark
--color-successoklch(0.645 0.185 150)oklch(0.645 0.185 150)
--color-warningoklch(0.75 0.18 85)oklch(0.75 0.18 85)
--color-infooklch(0.65 0.15 250)oklch(0.65 0.15 250)

Available as --gray-50 through --gray-950 for direct use in components.

The render_utility_classes() function produces classes like:

  • .bg-background, .bg-card, .bg-popover, .bg-muted
  • .text-foreground, .text-muted-foreground, .text-card-foreground
  • .border-border, .border-input
  • .rounded-custom

The UI_CSP_REQUIREMENTS constant provides Content Security Policy directives:

from lexigram.ui.constants import UI_CSP_REQUIREMENTS

Add these to your application’s CSP headers when using lexigram-ui with external CDN assets (HTMX, Alpine.js, Lucide icons, Tailwind CDN).


flowchart LR
    subgraph Sources[Config Sources]
        YAML[application.yaml<br/>ui: section]
        ENV[Environment variables<br/>LEX_UI__*]
        PyCall[Python API<br/>UIConfig(...)]
    end
    subgraph Merge[Merge & Validate]
        UC[UIConfig<br/>validate_for_environment]
    end
    subgraph DI[DI Registration]
        UP[UIProvider.register]
        CS[container.singleton<br/>UIConfig, config]
    end
    subgraph App[Application]
        Resolved[Resolved UIConfig<br/>available via container]
    end

    YAML --> UC
    ENV --> UC
    PyCall --> UC
    UC --> UP
    UP --> CS
    CS --> Resolved

Config is loaded from application.yaml:

ui:
default_theme: default
theme: dark
enable_sse: true
debug_components: false

Or via environment variables:

Terminal window
export LEX_UI__THEME=dark
export LEX_UI__ENABLE_SSE=true

The UIConfig class supports validate_for_environment() which warns when debug_components is enabled in production.

During DI registration, UIProvider.register() calls container.singleton(UIConfig, config) so the resolved config instance is available throughout the application.