fh-matui
What is fh-matui?
fh-matui is a Python library that brings Googleβs Material Design to FastHTML applications. It provides a comprehensive set of pre-built UI components that integrate seamlessly with FastHTMLβs hypermedia-driven architecture.
Built on top of BeerCSS (a lightweight Material Design 3 CSS framework), fh-matui enables you to create modern, responsive web interfaces entirely in Python β no JavaScript required.
β¨ Key Features
| Feature | Description |
|---|---|
| π¨ Material Design 3 | Modern, beautiful components following Googleβs latest design language |
| β‘ Zero JavaScript | Build interactive UIs entirely in Python with FastHTML |
| π± Responsive | Mobile-first design with automatic breakpoint handling |
| π Dark Mode | Built-in light/dark theme support with 20+ color schemes |
| π§© Composable | Chainable styling APIs inspired by MonsterUI |
| π Data Tables | Full-featured tables with pagination, search, sorting, and CRUD |
| π§ nbdev-powered | Literate programming with documentation built from notebooks |
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β fh-matui β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Foundations β Core styling utilities, helpers, enums β
β Core β Theme system, MatTheme color presets β
β Components β Buttons, Cards, Modals, Forms, Tables β
β App Pages β Full-page layouts, navigation patterns β
β Data Tables β DataTable, DataTableResource for CRUD β
β Web Pages β Landing pages, marketing components β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BeerCSS β Material Design 3 CSS framework β
β FastHTML β Python hypermedia web framework β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π¨ Available Themes
fh-matui includes 15+ pre-configured Material Design 3 color themes:
| Theme | Preview | Theme | Preview |
|---|---|---|---|
MatTheme.red |
π΄ | MatTheme.pink |
π©· |
MatTheme.purple |
π£ | MatTheme.deep_purple |
π |
MatTheme.indigo |
π΅ | MatTheme.blue |
π |
MatTheme.light_blue |
π©΅ | MatTheme.cyan |
π |
MatTheme.teal |
π©Ά | MatTheme.green |
π |
MatTheme.light_green |
π | MatTheme.lime |
π |
MatTheme.yellow |
π | MatTheme.amber |
π§‘ |
MatTheme.orange |
π | MatTheme.deep_orange |
πΆ |
MatTheme.brown |
π€ | MatTheme.grey |
βͺ |
MatTheme.blue_grey |
π |
Usage:
# Choose your theme
app, rt = fast_app(hdrs=[MatTheme.deep_purple.headers()])π Quick Start
Hereβs a minimal example to get you started:
from fasthtml.common import *
from fh_matui.core import MatTheme
from fh_matui.components import Button, Card, FormField
# Create a themed FastHTML app
app, rt = fast_app(hdrs=[MatTheme.indigo.headers()])
@rt('/')
def home():
return Div(
Card(
H3("Welcome to fh-matui!"),
P("Build beautiful Material Design apps with Python."),
Button("Get Started", cls="primary"),
),
cls="padding"
)
serve()π¦ Installation
pip install fh-matuiDependencies
fh-matui automatically includes: - python-fasthtml - The core FastHTML framework - BeerCSS - Loaded via CDN for Material Design 3 styling
What This Code Does
π Module Reference
| Module | Description | Key Components |
|---|---|---|
| Foundations | Base utilities and helper functions | BeerHeaders, display, styling helpers |
| Core | Theme system and styling | MatTheme, color presets, theme configuration |
| Components | UI component library | Button, Card, FormField, FormModal, Grid |
| App Pages | Application layouts | Navigation, sidebars, full-page layouts |
| Data Tables | Data management components | DataTable, DataTableResource, CRUD operations |
| Web Pages | Marketing/landing pages | Hero sections, feature grids, testimonials |
π οΈ Development
Install in Development Mode
# Clone the repository
git clone https://github.com/user/fh-matui.git
cd fh-matui
# Install in editable mode
pip install -e .
# Make changes under nbs/ directory, then compile
nbdev_prepareπ€ Why fh-matui?
| Challenge | fh-matui Solution |
|---|---|
| CSS complexity | Pre-built Material Design 3 components via BeerCSS |
| JavaScript fatigue | FastHTML handles interactivity declaratively |
| Component consistency | Unified API across all components |
| Dark mode support | Built-in with automatic system preference detection |
| Responsive design | Mobile-first grid system and responsive utilities |
| Form handling | FormField, FormGrid, FormModal for rapid form building |
| Data management | DataTable and DataTableResource for CRUD operations |
π€ For LLM Users
fh-matui includes comprehensive documentation bundles for Large Language Models, enabling AI assistants (like Claude, ChatGPT, or GitHub Copilot) to help you build FastHTML apps with complete knowledge of the component APIs.
π₯ Download Context File
π llms-ctx.txt β Complete API documentation in LLM-optimized format
π‘ How to Use
- Download the context file from the link above
- Attach it to your LLM conversation (drag & drop or paste contents)
- Ask for implementation using natural language
Example Prompt:
I'm using fh-matui (context attached). Create a dashboard with:
- A sidebar navigation with 5 menu items
- A DataTable showing products with pagination
- A modal form to add/edit products
- Use the deep purple theme
The LLM will generate production-ready FastHTML code using the exact component APIs from the documentation.
π Staying Up to Date
The llms-ctx.txt file is automatically regenerated with each release to ensure it stays synchronized with the latest API changes. Always download the version matching your installed package version for the most accurate results.
π Note: The context file is generated from the same literate programming notebooks that build the library itself, ensuring 100% accuracy with the actual implementation.
π License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Built with β€οΈ using FastHTML and nbdev