Documentation
¶
Overview ¶
Package forgeui is an SSR-first UI component library for Go
ForgeUI provides type-safe, composable UI components built on gomponents with Alpine.js interactivity, Tailwind CSS styling, and shadcn-inspired design.
Key Features:
- SSR-first with progressive enhancement
- Pure Go API with full type safety
- CVA (Class Variance Authority) for variant management
- Functional options pattern for flexible configuration
- Comprehensive component library
- Plugin system for extensibility
Basic usage:
app := forgeui.New(
forgeui.WithDebug(true),
forgeui.WithThemeName("default"),
)
if err := app.Initialize(context.Background()); err != nil {
log.Fatal(err)
}
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
- animation: Animation and transition utilities
- assets: Asset management and fingerprinting
- primitives: Low-level layout primitives
- components: 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) Bridge() *bridge.Bridge
- 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) 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) Initialize(ctx context.Context) error
- 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) Theme() *theme.Theme
- func (a *App) Use(middleware ...router.Middleware) *App
- type AppConfig
- type AppOption
- func WithAppStaticPath(path string) 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 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 WithStaticPath(path string) AppOption
- func WithThemeName(theme string) AppOption
- func WithThemes(light, dark *theme.Theme) AppOption
- type BaseProps
- type CVA
- type ComponentError
- type CompoundVariant
- type Configdeprecated
- type ConfigOption
- type Node
- 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) 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) Initialize ¶
Initialize prepares the application (plugins, router, assets, etc.) This will be expanded in later phases as more systems are added
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
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
// Bridge configuration (optional)
BridgeConfig *bridge.Config
EnableBridge bool
// Theme configuration (enhanced)
LightTheme *theme.Theme
DarkTheme *theme.Theme
// DefaultLayout is the default layout name for all pages
DefaultLayout string
// StaticPath is the URL path for static assets
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 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 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 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
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 Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node wraps gomponents.Node with a fluent API for building HTML elements
func (*Node) Build ¶
Build renders the node to a gomponents.Node This is the final step that produces the actual renderable element
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
|
|
|
accordion
Package accordion provides collapsible accordion components following shadcn/ui patterns.
|
Package accordion provides collapsible accordion components following shadcn/ui patterns. |
|
alert
Package alert provides alert components with different variants.
|
Package alert provides alert components with different variants. |
|
avatar
Package avatar provides avatar components with image and fallback support.
|
Package avatar provides avatar components with image and fallback support. |
|
badge
Package badge provides badge/tag components with variant support.
|
Package badge provides badge/tag components with variant support. |
|
breadcrumb
Package breadcrumb provides breadcrumb navigation components following shadcn/ui patterns.
|
Package breadcrumb provides breadcrumb navigation components following shadcn/ui patterns. |
|
button
Package button provides button components with multiple variants, sizes, and states following shadcn/ui design patterns.
|
Package button provides button components with multiple variants, sizes, and states following shadcn/ui design patterns. |
|
card
Package card provides card components following shadcn/ui patterns.
|
Package card provides card components following shadcn/ui patterns. |
|
checkbox
Package checkbox provides checkbox components.
|
Package checkbox provides checkbox components. |
|
dropdown
Package dropdown provides dropdown menu components with keyboard navigation.
|
Package dropdown provides dropdown menu components with keyboard navigation. |
|
emptystate
Package emptystate provides an EmptyState component for displaying "no data" or "empty results" scenarios with optional icons, text, and actions.
|
Package emptystate provides an EmptyState component for displaying "no data" or "empty results" scenarios with optional icons, text, and actions. |
|
form
Package form provides form wrapper and validation helpers.
|
Package form provides form wrapper and validation helpers. |
|
input
Package input provides input components for forms.
|
Package input provides input components for forms. |
|
label
Package label provides label components for form fields.
|
Package label provides label components for form fields. |
|
list
Package list provides list components for displaying items in ordered or unordered lists with various styling options.
|
Package list provides list components for displaying items in ordered or unordered lists with various styling options. |
|
menu
Package menu provides menu and navigation components following shadcn/ui patterns.
|
Package menu provides menu and navigation components following shadcn/ui patterns. |
|
modal
Package modal provides modal dialog components with Alpine.js state management.
|
Package modal provides modal dialog components with Alpine.js state management. |
|
pagination
Package pagination provides pagination components following shadcn/ui patterns.
|
Package pagination provides pagination components following shadcn/ui patterns. |
|
popover
Package popover provides floating content anchored to a trigger element.
|
Package popover provides floating content anchored to a trigger element. |
|
progress
Package progress provides progress bar components.
|
Package progress provides progress bar components. |
|
radio
Package radio provides radio button components.
|
Package radio provides radio button components. |
|
select
Package selectc provides select dropdown components matching shadcn/ui design.
|
Package selectc provides select dropdown components matching shadcn/ui design. |
|
separator
Package separator provides horizontal and vertical separators.
|
Package separator provides horizontal and vertical separators. |
|
sidebar
Package sidebar provides sidebar navigation components with provider pattern integration.
|
Package sidebar provides sidebar navigation components with provider pattern integration. |
|
skeleton
Package skeleton provides skeleton loading placeholders.
|
Package skeleton provides skeleton loading placeholders. |
|
slider
Package slider provides range slider components.
|
Package slider provides range slider components. |
|
spinner
Package spinner provides loading spinner components.
|
Package spinner provides loading spinner components. |
|
switch
Package switchc provides toggle switch components.
|
Package switchc provides toggle switch components. |
|
table
Package table provides table components for displaying tabular data.
|
Package table provides table components for displaying tabular data. |
|
tabs
Package tabs provides tab components following shadcn/ui patterns.
|
Package tabs provides tab components following shadcn/ui patterns. |
|
textarea
Package textarea provides textarea components for multi-line text input.
|
Package textarea provides textarea components for multi-line text input. |
|
toast
Package toast provides notification system with queue management.
|
Package toast provides notification system with queue management. |
|
tooltip
Package tooltip provides small informational popups on hover or focus.
|
Package tooltip provides small informational popups on hover or focus. |
|
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 layout provides composable layout builders for ForgeUI applications.
|
Package layout provides composable layout builders for ForgeUI applications. |
|
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. |