Minty is a fresh, ultra-concise, type-safe HTML generation library for Go web applications. It provides a fluent API for creating HTML components without traditional templates, offering compile-time safety and excellent IDE support.
- Type-safe HTML generation - Catch errors at compile time, not runtime
- Fluent builder pattern - Intuitive, chainable API
- Dynamic client-side components - Without writing any Javascript by hand
- HTMX integration - First-class support for HTMX attributes and patterns
- Theme system - Pluggable themes (Bootstrap, Tailwind, Bulma, Material Design)
- Domain libraries - Pre-built components for common business domains
- Control flow helpers - If, IfElse, Each, Map, Filter, and more
- Zero dependencies - Pure Go, no external requirements
go get github.com/ha1tch/mintypackage main
import (
"os"
mi "github.com/ha1tch/minty"
)
func main() {
// Create a simple page
page := func(b *mi.Builder) mi.Node {
return b.Html(
b.Head(b.Title("Hello Minty")),
b.Body(
b.H1(mi.Class("title"), "Welcome!"),
b.P("This is a paragraph."),
b.A(mi.Href("/about"), "Learn more"),
),
)
}
// Render to stdout
mi.Render(page, os.Stdout)
}github.com/ha1tch/minty
├── / # Core library (HTML builder, attributes, HTMX)
├── mintytypes/ # Pure business types (Money, Address, Status, etc.)
├── mintyex/ # Extensions (UI helpers, re-exports mintytypes)
├── mintyui/ # UI component abstractions (Theme interface)
├── domains/ # Business domain libraries (depend only on mintytypes)
│ ├── mintyfin/ # Finance domain (accounts, transactions, invoices)
│ ├── mintycart/ # E-commerce domain (products, carts, orders)
│ └── mintymove/ # Logistics domain (shipments, tracking, vehicles)
├── presentation/ # UI adapters (domain → themed components)
│ ├── mintyfinui/
│ ├── mintycartui/
│ └── mintymoveui/
├── themes/ # Theme implementations
│ ├── bootstrap/ # Bootstrap 5 theme
│ ├── tailwind/ # Tailwind CSS theme
│ ├── bulma/ # Bulma CSS theme
│ └── material/ # Material Design theme
├── examples/ # Example applications
└── docs/ # Comprehensive documentation
The dependency graph enforces clean architecture:
mintytypes (pure - no dependencies)
↗ ↖
minty domains/*
↖ ↗
mintyex
↑
presentation/*
- mintytypes: Pure business types with zero external dependencies
- domains: Business logic depends only on mintytypes (no UI knowledge)
- mintyex: UI helpers + re-exports mintytypes for convenience
- presentation: Adapts domain data to themed UI components
All HTML elements are created through the Builder type. Use the global B instance or create your own:
import mi "github.com/ha1tch/minty"
// Using global builder
div := mi.B.Div(mi.Class("container"), "Hello")
// Using builder in templates (most common)
template := func(b *mi.Builder) mi.Node {
return b.Div(mi.Class("container"),
b.H1("Title"),
b.P("Content"),
)
}Attributes are created using helper functions:
b.A(
mi.Href("/page"),
mi.Class("nav-link"),
mi.Target("_blank"),
mi.Rel("noopener"),
"Click me",
)First-class HTMX support:
b.Button(
mi.Class("btn"),
mi.HtmxPost("/api/submit"),
mi.HtmxTarget("#result"),
mi.HtmxSwap("innerHTML"),
mi.HtmxIndicator("#spinner"),
"Submit",
)Conditional rendering:
mi.If(isLoggedIn, userGreeting)
mi.IfElse(hasItems, itemsList, emptyMessage)
mi.Each(items, func(item Item) mi.H {
return func(b *mi.Builder) mi.Node {
return b.Li(item.Name)
}
})Use pre-built themes for consistent styling:
import (
mi "github.com/ha1tch/minty"
"github.com/ha1tch/minty/themes/bootstrap"
)
theme := bootstrap.NewBootstrapTheme()
// Use themed components
button := theme.Button("Click me", "primary")
card := theme.Card("Title", content)
form := theme.FormInput("Email", "email", "email")Comprehensive documentation is available in the /docs directory:
- Introduction - Getting started
- Design Philosophy - Architecture decisions
- Architecture - System design
- Syntax & API - Complete API reference
- Components - Component library
- HTMX Integration - HTMX patterns
- Business Domains - Domain libraries
- Iterators - Collection utilities
- Themes - Theme system
- Presentation Layer - UI patterns
- JavaScript Integration - JS interop
Run the simple example:
cd examples/simple
go run main.goAll packages compile and tests pass.
- Core library (HTML builder, attributes)
- HTMX integration
- Theme system (Bootstrap, Tailwind, Bulma, Material)
- Domain libraries (mintyfin, mintycart, mintymove)
- Extensions (mintyex)
- UI abstractions (mintyui)
- Presentation adapters (mintycartui, mintyfinui, mintymoveui)
For consistency across the codebase, use these import aliases:
import (
mi "github.com/ha1tch/minty" // Core library
mt "github.com/ha1tch/minty/mintytypes" // Pure business types
miex "github.com/ha1tch/minty/mintyex" // Extensions (includes mt re-exports)
mui "github.com/ha1tch/minty/mintyui" // UI components
// Domain packages (import mt, not miex)
mifi "github.com/ha1tch/minty/domains/mintyfin" // Finance
mica "github.com/ha1tch/minty/domains/mintycart" // E-commerce
mimo "github.com/ha1tch/minty/domains/mintymove" // Logistics
)Note: Domain packages import mintytypes directly (as mt) to maintain clean architecture. Presentation layers can import mintyex which re-exports all types for convenience.
Apache 2.0
https://github.com/ha1tch/minty?tab=Apache-2.0-1-ov-file
Copyright (C)2026 haitch