Documentation
¶
Overview ¶
Package forgeui is an SSR-first UI framework for Go
ForgeUI provides a full-stack web application framework built on templ with Alpine.js interactivity, Tailwind CSS styling, and templui components.
Key Features:
- SSR-first with progressive enhancement
- Type-safe templ templates
- templui component library (shadcn-inspired)
- Alpine.js and HTMX integration helpers
- Functional options pattern for flexible configuration
- Plugin system for extensibility
Basic usage:
app := forgeui.New(
forgeui.WithDebug(true),
forgeui.WithThemeName("default"),
)
app.Get("/", func(ctx *router.PageContext) (templ.Component, error) {
return HomePage(), nil
})
http.ListenAndServe(":3000", app.Handler())
Subpackages:
- plugin: Plugin system for extending ForgeUI functionality
- router: HTTP routing with layouts, loaders, and middleware
- theme: Theme system with dark mode support
- alpine: Alpine.js integration helpers
- htmx: HTMX attribute helpers
- assets: Asset management and fingerprinting
- bridge: Go-JS RPC bridge
- primitives: Low-level layout primitives
- components: templui-based UI component library
- icons: Icon system with Lucide icons
Index ¶
- Constants
- func ApplyOptions[T any](props *T, opts []Option[T])
- func CN(classes ...string) string
- func If(condition bool, value string) string
- func IfElse(condition bool, trueVal, falseVal string) string
- func MapGet[K comparable, V any](m map[K]V, key K, defaultVal V) V
- func ThemeFromContext(ctx context.Context) (any, bool)
- func ToString(v any) string
- func WithConfig(ctx context.Context, config *Config) context.Context
- func WithTheme(ctx context.Context, theme any) context.Context
- type Align
- type App
- func (a *App) AlpineBridgeScriptPath() string
- func (a *App) Bridge() *bridge.Bridge
- func (a *App) BridgeCallPath() string
- func (a *App) BridgeScriptPath() string
- func (a *App) BridgeScripts(includeAlpine bool, csrfToken ...string) templ.Component
- func (a *App) BridgeStreamPath() string
- func (a *App) CSSPath() string
- func (a *App) Config() *AppConfig
- func (a *App) DarkTheme() *theme.Theme
- func (a *App) Delete(pattern string, handler router.PageHandler) *router.Route
- func (a *App) FontFaceCSS() string
- func (a *App) FontPreloadLinks() templ.Component
- func (a *App) Get(pattern string, handler router.PageHandler) *router.Route
- func (a *App) Group(prefix string) *router.Group
- func (a *App) Handler() http.Handler
- func (a *App) HasBridge() bool
- func (a *App) HotReloadPath() string
- func (a *App) Initialize(ctx context.Context) error
- func (a *App) IsCDNMode() bool
- func (a *App) IsDev() bool
- func (a *App) LightTheme() *theme.Theme
- func (a *App) Page(pattern string) *PageBuilder
- func (a *App) Patch(pattern string, handler router.PageHandler) *router.Route
- func (a *App) Post(pattern string, handler router.PageHandler) *router.Route
- func (a *App) Put(pattern string, handler router.PageHandler) *router.Route
- func (a *App) RegisterLayout(name string, fn router.LayoutFunc, opts ...router.LayoutOption)
- func (a *App) Router() *router.Router
- func (a *App) StaticPath() string
- func (a *App) Theme() *theme.Theme
- func (a *App) ThemeStylesheet() templ.Component
- func (a *App) Use(middleware ...router.Middleware) *App
- type AppConfig
- type AppOption
- func WithAppStaticPath(path string) AppOption
- func WithAssetFileSystem(fsys fs.FS) AppOption
- func WithAssetManifest(path string) AppOption
- func WithAssetOutputDir(dir string) AppOption
- func WithAssetPublicDir(dir string) AppOption
- func WithAssets(publicDir string, opts ...string) AppOption
- func WithAssetsPath(path string) AppOption
- func WithBasePath(path string) AppOption
- func WithBridge(opts ...bridge.ConfigOption) AppOption
- func WithDebug(debug bool) AppOption
- func WithDefaultLayout(layout string) AppOption
- func WithDefaultRadius(radius Radius) AppOption
- func WithDefaultSize(size Size) AppOption
- func WithDefaultVariant(variant Variant) AppOption
- func WithDev(dev bool) AppOption
- func WithEmbedFS(fsys fs.FS) AppOption
- func WithFonts(fc *theme.FontConfig) AppOption
- func WithInputCSS(path string) AppOption
- func WithStaticPath(path string) AppOption
- func WithThemeName(theme string) AppOption
- func WithThemes(light, dark *theme.Theme) AppOption
- func WithVerbose(verbose bool) AppOption
- type BaseProps
- type CVA
- type ComponentError
- type CompoundVariant
- type Configdeprecated
- type ConfigOption
- type Option
- type PageBuilder
- func (pb *PageBuilder) DELETE() *PageBuilder
- func (pb *PageBuilder) GET() *PageBuilder
- func (pb *PageBuilder) Handler(handler router.PageHandler) *PageBuilder
- func (pb *PageBuilder) Layout(layout string) *PageBuilder
- func (pb *PageBuilder) Loader(loader router.LoaderFunc) *PageBuilder
- func (pb *PageBuilder) Meta(title, description string) *PageBuilder
- func (pb *PageBuilder) MetaFull(meta *router.RouteMeta) *PageBuilder
- func (pb *PageBuilder) Method(method string) *PageBuilder
- func (pb *PageBuilder) Middleware(middleware ...router.Middleware) *PageBuilder
- func (pb *PageBuilder) Name(name string) *PageBuilder
- func (pb *PageBuilder) NoLayout() *PageBuilder
- func (pb *PageBuilder) PATCH() *PageBuilder
- func (pb *PageBuilder) POST() *PageBuilder
- func (pb *PageBuilder) PUT() *PageBuilder
- func (pb *PageBuilder) Register() *router.Route
- type PluginError
- type Position
- type Props
- type Radius
- type Side
- type Size
- type ValidationError
- type Variant
Constants ¶
const Version = "0.0.3"
Version is the current version of ForgeUI
Variables ¶
This section is empty.
Functions ¶
func ApplyOptions ¶
ApplyOptions applies a slice of options to props This is a helper function for components to apply functional options
func CN ¶
CN (ClassName) merges class names, filtering empty strings This is useful for combining multiple class strings with conditional classes
func If ¶
If returns the value if condition is true, empty string otherwise Useful for conditional class application
func IfElse ¶
IfElse returns trueVal if condition is true, falseVal otherwise Useful for binary conditional class application
func MapGet ¶
func MapGet[K comparable, V any](m map[K]V, key K, defaultVal V) V
MapGet returns map value or default value if key doesn't exist Generic helper for safely accessing maps with defaults
func ThemeFromContext ¶
ThemeFromContext retrieves theme from context
func WithConfig ¶
WithConfig adds config to context
Types ¶
type App ¶
App is the main ForgeUI application with enhanced features
func (*App) AlpineBridgeScriptPath ¶ added in v0.0.8
AlpineBridgeScriptPath returns the full path to the Alpine bridge JavaScript file
func (*App) BridgeCallPath ¶ added in v0.0.8
BridgeCallPath returns the full bridge call endpoint path
func (*App) BridgeScriptPath ¶ added in v0.0.8
BridgeScriptPath returns the full path to the bridge JavaScript file
func (*App) BridgeScripts ¶ added in v0.0.8
BridgeScripts returns properly configured bridge script tags as a templ.Component. This respects the BasePath configuration.
func (*App) BridgeStreamPath ¶ added in v0.0.8
BridgeStreamPath returns the full bridge stream endpoint path
func (*App) CSSPath ¶ added in v1.0.0
CSSPath returns the URL path to the compiled CSS stylesheet. This respects the BasePath and StaticPath configuration.
func (*App) FontFaceCSS ¶ added in v1.0.0
FontFaceCSS returns the @font-face CSS rules for all configured fonts. Returns an empty string if no font config is set.
func (*App) FontPreloadLinks ¶ added in v1.0.0
FontPreloadLinks returns a templ.Component that renders <link rel="preload"> tags for all configured fonts that have Preload: true. Returns a nop component if no font config is set.
func (*App) Handler ¶ added in v0.0.2
Handler returns an http.Handler that serves the entire application This includes static assets, bridge endpoints, and routed pages
func (*App) HotReloadPath ¶ added in v0.0.8
HotReloadPath returns the full hot reload SSE endpoint path
func (*App) Initialize ¶
Initialize prepares the application (plugins, router, assets, etc.) This will be expanded in later phases as more systems are added
func (*App) IsCDNMode ¶ added in v1.0.0
IsCDNMode returns true if compiled CSS was not built (e.g., Tailwind CLI not available). When in CDN mode, layouts should include the Tailwind CDN script and inline theme styles.
func (*App) LightTheme ¶ added in v0.0.2
LightTheme returns the light theme
func (*App) Page ¶ added in v0.0.2
func (a *App) Page(pattern string) *PageBuilder
Page creates a new PageBuilder for fluent page registration
func (*App) RegisterLayout ¶ added in v0.0.2
func (a *App) RegisterLayout(name string, fn router.LayoutFunc, opts ...router.LayoutOption)
RegisterLayout registers a named layout
func (*App) StaticPath ¶ added in v1.0.0
StaticPath returns the full URL path prefix for static assets.
func (*App) ThemeStylesheet ¶ added in v1.0.0
ThemeStylesheet returns a <link rel="stylesheet"> templ.Component for the compiled CSS. Returns a nop component if CSS was not compiled (CDN mode).
type AppConfig ¶
type AppConfig struct {
// Debug enables debug/development mode
Debug bool
// Theme is the active theme name (legacy support)
Theme string
// AssetPublicDir is the source directory for static assets
AssetPublicDir string
// AssetOutputDir is the output directory for processed assets
AssetOutputDir string
// AssetManifest is the path to a manifest file for production builds
AssetManifest string
// AssetFileSystem is an optional custom filesystem for assets (e.g., embed.FS)
AssetFileSystem fs.FS
// Bridge configuration (optional)
BridgeConfig *bridge.Config
EnableBridge bool
// Theme configuration (enhanced)
LightTheme *theme.Theme
DarkTheme *theme.Theme
// FontConfig holds typography configuration (fonts, preloading, etc.)
FontConfig *theme.FontConfig
// DefaultLayout is the default layout name for all pages
DefaultLayout string
// InputCSS is an optional path to a custom Tailwind v4 input CSS file.
// When set, this is used instead of auto-generating one from themes.
InputCSS string
// Verbose enables detailed logging for asset processing and other subsystems.
Verbose bool
// BasePath is the base URL path for all ForgeUI routes (static, bridge, etc.)
// Example: "/api/identity/ui" results in:
// - Static: /api/identity/ui/static/...
// - Bridge: /api/identity/ui/bridge/...
BasePath string
// StaticPath is the URL path for static assets (relative to BasePath if set)
// Default: "/static"
StaticPath string
// Component defaults (from legacy Config)
DefaultSize Size
DefaultVariant Variant
DefaultRadius Radius
}
AppConfig holds enhanced ForgeUI application configuration
func DefaultAppConfig ¶
func DefaultAppConfig() *AppConfig
DefaultAppConfig returns sensible defaults for ForgeUI application
type AppOption ¶
type AppOption func(*AppConfig)
AppOption is a functional option for configuring the App
func WithAppStaticPath ¶
WithAppStaticPath sets the URL path for static assets
func WithAssetFileSystem ¶ added in v0.0.8
WithAssetFileSystem sets a custom filesystem for serving assets (e.g., embed.FS) This is useful when embedding assets in the binary or using custom filesystem implementations
func WithAssetManifest ¶
WithAssetManifest sets the path to a manifest file for production builds
func WithAssetOutputDir ¶
WithAssetOutputDir sets the output directory for processed assets
func WithAssetPublicDir ¶
WithAssetPublicDir sets the source directory for static assets
func WithAssets ¶
WithAssets sets the asset directories
func WithAssetsPath ¶
WithAssetsPath sets the filesystem assets path (deprecated, use WithAssetPublicDir)
func WithBasePath ¶ added in v0.0.8
WithBasePath sets the base URL path for all ForgeUI routes This prefixes static, bridge, and other ForgeUI endpoints Example: WithBasePath("/api/identity/ui") results in:
- Static: /api/identity/ui/static/...
- Bridge: /api/identity/ui/bridge/...
func WithBridge ¶
func WithBridge(opts ...bridge.ConfigOption) AppOption
WithBridge enables and configures the bridge system
func WithDefaultLayout ¶
WithDefaultLayout sets the default layout for all pages
func WithDefaultRadius ¶
WithDefaultRadius sets the default border radius
func WithDefaultSize ¶
WithDefaultSize sets the default component size
func WithDefaultVariant ¶
WithDefaultVariant sets the default component variant
func WithEmbedFS ¶ added in v0.0.8
WithEmbedFS is an alias for WithAssetFileSystem for better discoverability
func WithFonts ¶ added in v1.0.0
func WithFonts(fc *theme.FontConfig) AppOption
WithFonts sets the font configuration for the application. This enables font preloading and @font-face generation.
func WithInputCSS ¶ added in v1.0.0
WithInputCSS sets a custom Tailwind v4 input CSS file. When set, this is used instead of auto-generating one from themes.
func WithStaticPath ¶
WithStaticPath sets the static assets path (alias for WithAppStaticPath)
func WithThemeName ¶
WithThemeName sets the theme name (legacy support)
func WithThemes ¶
WithThemes sets the light and dark themes
func WithVerbose ¶ added in v1.0.0
WithVerbose enables verbose logging for asset processing
type CVA ¶
type CVA struct {
// contains filtered or unexported fields
}
CVA (Class Variance Authority) manages component class variants It provides a type-safe way to handle component variants and their combinations
func NewCVA ¶
NewCVA creates a new CVA instance with base classes Base classes are always included in the output
func (*CVA) Classes ¶
Classes generates the final class string based on the provided variant values It combines base classes, variant-specific classes, and compound variant classes
func (*CVA) Compound ¶
Compound adds a compound variant rule that applies classes when multiple conditions match Example: cva.Compound(map[string]string{"size": "sm", "variant": "primary"}, "extra-class")
type ComponentError ¶
ComponentError represents an error in component rendering
func (*ComponentError) Error ¶
func (e *ComponentError) Error() string
func (*ComponentError) Unwrap ¶
func (e *ComponentError) Unwrap() error
type CompoundVariant ¶
CompoundVariant applies classes when multiple conditions match
type Config
deprecated
type Config struct {
// Debug enables debug mode
Debug bool
// Theme is the active theme name
Theme string
// StaticPath is the URL path for static assets
StaticPath string
// AssetsPath is the filesystem path for assets (deprecated, use AssetPublicDir)
AssetsPath string
// AssetPublicDir is the source directory for static assets
AssetPublicDir string
// AssetOutputDir is the output directory for processed assets
AssetOutputDir string
// AssetManifest is the path to a manifest file for production builds
AssetManifest string
// DefaultSize is the default component size
DefaultSize Size
// DefaultVariant is the default component variant
DefaultVariant Variant
// DefaultRadius is the default border radius
DefaultRadius Radius
}
Config holds ForgeUI application configuration
Deprecated: Use AppConfig instead. Config is kept for backward compatibility.
func ConfigFromContext ¶
ConfigFromContext retrieves config from context
func DefaultConfig
deprecated
func DefaultConfig() *Config
DefaultConfig returns sensible defaults for ForgeUI configuration
Deprecated: Use DefaultAppConfig instead
type ConfigOption ¶
type ConfigOption = AppOption
ConfigOption is a functional option for Config Note: ConfigOption is now an alias for AppOption for unified configuration
type Option ¶
type Option[T any] func(*T)
Option is a generic functional option type for configuring component properties
type PageBuilder ¶
type PageBuilder struct {
// contains filtered or unexported fields
}
PageBuilder provides a fluent API for building and registering pages
func (*PageBuilder) DELETE ¶
func (pb *PageBuilder) DELETE() *PageBuilder
DELETE is a convenience method to set method to DELETE
func (*PageBuilder) GET ¶
func (pb *PageBuilder) GET() *PageBuilder
GET is a convenience method to set method to GET
func (*PageBuilder) Handler ¶
func (pb *PageBuilder) Handler(handler router.PageHandler) *PageBuilder
Handler sets the page handler function
func (*PageBuilder) Layout ¶
func (pb *PageBuilder) Layout(layout string) *PageBuilder
Layout sets the layout name for this page
func (*PageBuilder) Loader ¶
func (pb *PageBuilder) Loader(loader router.LoaderFunc) *PageBuilder
Loader sets the data loader function
func (*PageBuilder) Meta ¶
func (pb *PageBuilder) Meta(title, description string) *PageBuilder
Meta sets the page metadata (title and description)
func (*PageBuilder) MetaFull ¶
func (pb *PageBuilder) MetaFull(meta *router.RouteMeta) *PageBuilder
MetaFull sets complete page metadata
func (*PageBuilder) Method ¶
func (pb *PageBuilder) Method(method string) *PageBuilder
Method sets the HTTP method for this page
func (*PageBuilder) Middleware ¶
func (pb *PageBuilder) Middleware(middleware ...router.Middleware) *PageBuilder
Middleware adds middleware to this page
func (*PageBuilder) Name ¶
func (pb *PageBuilder) Name(name string) *PageBuilder
Name sets a name for this route (for URL generation)
func (*PageBuilder) NoLayout ¶
func (pb *PageBuilder) NoLayout() *PageBuilder
NoLayout disables layout for this page
func (*PageBuilder) PATCH ¶
func (pb *PageBuilder) PATCH() *PageBuilder
PATCH is a convenience method to set method to PATCH
func (*PageBuilder) POST ¶
func (pb *PageBuilder) POST() *PageBuilder
POST is a convenience method to set method to POST
func (*PageBuilder) PUT ¶
func (pb *PageBuilder) PUT() *PageBuilder
PUT is a convenience method to set method to PUT
func (*PageBuilder) Register ¶
func (pb *PageBuilder) Register() *router.Route
Register registers the page with the router
type PluginError ¶
PluginError represents a plugin-related error
func (*PluginError) Error ¶
func (e *PluginError) Error() string
func (*PluginError) Unwrap ¶
func (e *PluginError) Unwrap() error
type Position ¶
type Position string
Position represents positioning for floating elements (popovers, tooltips, dropdowns)
type Props ¶
type Props any
Props is the base interface for component properties Components can implement this interface to add validation
type ValidationError ¶
ValidationError represents a props validation error
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package alpine provides Alpine.js integration helpers for ForgeUI.
|
Package alpine provides Alpine.js integration helpers for ForgeUI. |
|
Package animation provides smooth transitions and animations for ForgeUI components.
|
Package animation provides smooth transitions and animations for ForgeUI components. |
|
Package cli provides a command-line interface framework for ForgeUI.
|
Package cli provides a command-line interface framework for ForgeUI. |
|
cmd
|
|
|
forgeui
command
|
|
|
components
|
|
|
icon
templui component icon - version: v1.5.0 installed by templui v1.5.0 📚 Documentation: https://templui.io/docs/components/icon
|
templui component icon - version: v1.5.0 installed by templui v1.5.0 📚 Documentation: https://templui.io/docs/components/icon |
|
Package htmx provides HTMX integration for ForgeUI.
|
Package htmx provides HTMX integration for ForgeUI. |
|
Package icons provides a flexible icon system with Lucide icon integration.
|
Package icons provides a flexible icon system with Lucide icon integration. |
|
Package plugin provides the ForgeUI plugin system.
|
Package plugin provides the ForgeUI plugin system. |
|
Package plugins provides convenience imports for all built-in ForgeUI plugins.
|
Package plugins provides convenience imports for all built-in ForgeUI plugins. |
|
analytics
Package analytics provides event tracking integration for ForgeUI.
|
Package analytics provides event tracking integration for ForgeUI. |
|
charts
Package charts provides data visualization components using Chart.js.
|
Package charts provides data visualization components using Chart.js. |
|
htmxplugin
Package htmxplugin provides an HTMX plugin wrapper for ForgeUI's plugin system.
|
Package htmxplugin provides an HTMX plugin wrapper for ForgeUI's plugin system. |
|
seo
Package seo provides SEO meta tag and structured data management for ForgeUI.
|
Package seo provides SEO meta tag and structured data management for ForgeUI. |
|
sortable
Package sortable provides drag-and-drop list reordering using SortableJS.
|
Package sortable provides drag-and-drop list reordering using SortableJS. |
|
themes/corporate
Package corporate provides a professional theme preset for business applications.
|
Package corporate provides a professional theme preset for business applications. |
|
toast
Package toast provides a toast notification plugin for ForgeUI.
|
Package toast provides a toast notification plugin for ForgeUI. |
|
Package primitives provides low-level layout primitives for ForgeUI.
|
Package primitives provides low-level layout primitives for ForgeUI. |
|
Package theme provides a comprehensive theming system with color tokens, dark mode support, and CSS generation following shadcn/ui design patterns.
|
Package theme provides a comprehensive theming system with color tokens, dark mode support, and CSS generation following shadcn/ui design patterns. |
|
templui util templui.go - version: v1.5.0 installed by templui v1.5.0
|
templui util templui.go - version: v1.5.0 installed by templui v1.5.0 |