A comprehensive Go theming package for web applications. The web counterpart to bubbletint.
- 450+ Built-in Themes - Dracula, Nord, Gruvbox, Tokyo Night, Catppuccin, and more
- Multiple Output Formats - CSS variables, SCSS, JSON, DTCG design tokens
- Syntax Highlighting - Compatible with Prism.js, Highlight.js, and Chroma
- WCAG Accessibility - Built-in contrast ratio validation
- Framework Agnostic - Works with any web framework (HTMX, React, Vue, Svelte, etc.)
- Custom Themes - Fluent builder API for creating custom themes
- Type Safe - Full Go type safety with comprehensive documentation
go get github.com/tj-smith47/gothememepackage main
import (
"fmt"
"github.com/tj-smith47/gothememe"
)
func main() {
// Initialize the default registry with all themes
gothememe.NewDefaultRegistry()
// Generate CSS for the current theme (Dracula by default)
css := gothememe.CSS(gothememe.DefaultCSSOptions())
fmt.Println(css)
}For applications with a single, application-wide theme:
gothememe.NewDefaultRegistry()
gothememe.SetThemeID("dracula")
// Generate CSS
css := gothememe.CSS(gothememe.DefaultCSSOptions())
// Access theme colors directly
bg := gothememe.Background()
text := gothememe.TextPrimary()
accent := gothememe.Accent()For applications that need runtime theme switching:
registry := gothememe.NewRegistry(
gothememe.ThemeDracula,
gothememe.ThemeNord,
)
// Navigate through themes
registry.NextTheme()
registry.PreviousTheme()
registry.SetThemeID("nord")
// Generate CSS for current theme
css := gothememe.GenerateCSS(registry.GetCurrentTheme(), gothememe.DefaultCSSOptions())For compile-time theme selection without a registry:
css := gothememe.GenerateCSS(gothememe.ThemeDracula, gothememe.DefaultCSSOptions())opts := gothememe.CSSOptions{
Prefix: "theme",
IncludeRoot: true,
}
css := gothememe.GenerateCSS(theme, opts)Output:
:root {
--theme-background: #282a36;
--theme-text-primary: #f8f8f2;
--theme-accent: #bd93f9;
/* ... */
}Generate CSS for all themes using data-theme attribute:
css := gothememe.AllThemesCSS(gothememe.DefaultCSSOptions())Output:
[data-theme="dracula"] { --theme-background: #282a36; ... }
[data-theme="nord"] { --theme-background: #2e3440; ... }Switch themes in HTML:
<html data-theme="dracula">Generate DTCG v1 compliant design tokens:
tokens, _ := gothememe.GenerateDesignTokens(theme, gothememe.DefaultTokenOptions())Generate CSS for code syntax highlighting:
// Prism.js compatible
syntaxCSS := gothememe.GenerateSyntaxCSS(theme, gothememe.SyntaxOptions{
Format: gothememe.SyntaxPrism,
UseVariables: true,
})
// Highlight.js compatible
syntaxCSS := gothememe.GenerateSyntaxCSS(theme, gothememe.SyntaxOptions{
Format: gothememe.SyntaxHighlightJS,
})theme := gothememe.NewThemeBuilder("my-theme", "My Custom Theme").
WithBackground(gothememe.Hex("#1a1a2e")).
WithTextPrimary(gothememe.Hex("#e4e4e4")).
WithAccent(gothememe.Hex("#e94560")).
WithGreen(gothememe.Hex("#22c55e")).
WithRed(gothememe.Hex("#ef4444")).
Build()Generate a complete theme from just 3 colors:
theme := gothememe.GenerateThemeFromPalette("minimal", "Minimal Theme", gothememe.Palette{
Background: gothememe.Hex("#1a1a2e"),
Foreground: gothememe.Hex("#e4e4e4"),
Accent: gothememe.Hex("#e94560"),
})theme := gothememe.DeriveTheme(gothememe.ThemeDracula, "dracula-custom", "Dracula Custom", map[string]gothememe.Color{
"accent": gothememe.Hex("#ff0000"),
})color := gothememe.Hex("#e94560")
// Modify colors
lighter := color.Lighten(0.1)
darker := color.Darken(0.1)
transparent := color.WithAlpha(0.5)
opposite := color.Complement()
mixed := color.Mix(gothememe.Hex("#ffffff"), 0.5)
// Convert formats
hex := color.Hex() // "#e94560"
rgb := color.CSSRGB() // "rgb(233, 69, 96)"
hsl := color.CSSHSL() // "hsl(350, 79%, 59%)"Check WCAG contrast requirements:
import "github.com/tj-smith47/gothememe/pkg/contrast"
// Calculate contrast ratio
ratio := contrast.RatioHex("#ffffff", "#000000") // 21.0
// Check compliance levels
meetsAA := contrast.MeetsAAHex("#f8f8f2", "#282a36", false) // true
meetsAAA := contrast.MeetsAAAHex("#f8f8f2", "#282a36", false) // true
// Get compliance level
level := contrast.CheckHex("#f8f8f2", "#282a36") // contrast.LevelAAAGenerate syntax highlighting CSS for use with Hugo, Chroma, Prism.js, or Highlight.js:
# Generate Chroma CSS for Dracula Pro (default)
syntaxgen > syntax.css
# Generate for a specific theme and format
syntaxgen -theme nord -format prism -output nord-prism.css
# List all available themes
syntaxgen -list
# Use CSS variables instead of inline colors
syntaxgen -theme catppuccin_mocha -variables > syntax.cssFlags:
-theme- Theme ID (default:dracula_pro)-format- Output format:chroma,prism,highlightjs(default:chroma)-output- Output file (default: stdout)-variables- Use CSS variables instead of inline colors-minify- Minify output-list- List available themes
Regenerate Go theme source files from iTerm2-Color-Schemes:
themegen -source iterm2 -output themesSee DEFAULT_THEMES.md for a complete list of themes with previews.
Popular themes include:
- Dracula, Dracula Plus
- Nord
- Gruvbox (Dark/Light)
- Tokyo Night (variants)
- Catppuccin (Frappe, Latte, Macchiato, Mocha)
- One Dark
- Solarized (Dark/Light)
- And 100+ more...
GoThemeMe works with any web framework. See docs/INTEGRATION.md for examples with:
- Vanilla HTML/CSS
- HTMX + templ
- React
- Vue
- Svelte
- Tailwind CSS
Contributions are welcome! See docs/CONTRIBUTING.md for guidelines.
Generated entirely by Claude Opus 4.5 over many iterations 🤖
MIT License - see LICENSE for details.
- Inspired by bubbletint by Liam Stanley
- Theme colors sourced from iTerm2-Color-Schemes
- Built with go-colorful
