🎯 Overview
This module provides the foundational building blocks for Material Design styling in FastHTML.
| 📦 Constants |
HEADER_URLS, beer_hdrs |
CDN links and header components |
| 🎨 Helper Lists |
SIZES, COLORS, MARGINS, etc. |
All BeerCSS utility class names |
| 🖌️ MatTheme |
MatTheme |
Fluent API for app theming (MatTheme.blue.headers()) |
| 🔗 BeerCssChain |
BeerCssChain |
Chainable CSS helper classes |
📚 Table of Contents
- CDN Headers - BeerCSS/Material Design CDN setup
- Helper Constants - Utility class name lists
- MatTheme API - App theming with color chains
- BeerCssChain - Chainable CSS helpers
🎨 Helper Constants
BeerCSS utility class names organized by category. These lists power BeerCssChain and can be used for validation.
| 📏 Sizing |
SIZES, WIDTH_HEIGHT |
small, large, auto_width |
| 🎭 Effects |
ELEVATES, BLURS, SHADOWS |
elevate, medium_blur, shadow |
| 📐 Layout |
MARGINS, PADDINGS, POSITIONS |
no_margin, left_padding, center |
| 🎨 Theme |
THEME_HELPERS, COLOR_HELPERS |
primary, dark, blue5 |
| ✍️ Text |
TYPOGRAPHY |
bold, italic, uppercase |
# Check available sizes
print(SIZES) # ['tiny', 'small', 'medium', 'large', 'extra', 'wrap', 'no_wrap', 'max']
# All helpers combined for validation
len(ALL_HELPERS) # 400+ utility classes available
['tiny', 'small', 'medium', 'large', 'extra', 'wrap', 'no_wrap', 'max']
🖌️ MatTheme API
Fluent API for configuring app themes with Material Design colors.
MatTheme.<color> |
Select a theme color (e.g., MatTheme.blue, MatTheme.amber) |
.headers(title, mode) |
Generate header tuple with theme scripts |
Available colors: amber, blue, red, green, purple, orange, cyan, teal, indigo, pink, lime, deep_orange, deep_purple, blue_grey, brown, yellow
💡 Use case: MatTheme.indigo.headers("My App", mode="dark") creates a dark-themed indigo app.
source
🔗 BeerCssChain
Chainable helper for building BeerCSS class strings with a fluent API.
BeerCssChain() |
Create empty chain |
.<helper> |
Chain any BeerCSS helper (e.g., .small, .primary, .bold) |
str(chain) |
Convert to space-separated class string |
💡 Use case: Build complex class strings without typos: BeerCssChain().small.primary.bold → "small primary bold"
source
BeerCssChain
def BeerCssChain(
tokens:NoneType=None
):
Base class for chaining Beer CSS helper classes together
# Chain multiple helpers
chain = BeerCssChain().small.primary.bold.round
str(chain) # "small primary bold round"
# Use with FastHTML components
Div("Hello", cls=str(BeerCssChain().large.center.padding))
# Iterate over tokens
list(BeerCssChain().small.margin.elevate) # ['small', 'margin', 'elevate']
['small', 'margin', 'elevate']