g-sui Framework
Server-rendered UI framework for Go. All HTML generation, business logic, and state management occur on the server. Interactivity achieved through server actions and WebSocket patches.
Quick Start
package main
import "github.com/michalCapo/g-sui/ui"
func main() {
app := ui.MakeApp("en")
app.Page("/", func(ctx *ui.Context) string {
return app.HTML("Home", "bg-gray-100",
ui.Div("p-8")(
ui.Div("text-2xl font-bold")("Hello World"),
),
)
})
app.Listen(":8080")
}
Documentation Index
| Topic |
File |
Description |
| Core Concepts |
CORE.md |
Architecture, Context, Actions, Targets, server rendering |
| UI Components |
COMPONENTS.md |
Buttons, inputs, forms, tables, alerts, cards, tabs, etc. |
| Data Management |
DATA.md |
Data collation, search, sort, filter, pagination, Excel export |
| Server Setup |
SERVER.md |
App initialization, routes, WebSocket, PWA, assets |
| Best Practices |
PATTERNS.md |
Testing, validation, security, state management |
Core Philosophy
- Server-Centric Rendering - All HTML generated server-side as strings
- String-Based Components - Components are Go functions returning HTML strings
- Action-Based Interactivity - User interactions trigger server handlers returning HTML
- WebSocket-Enhanced - Real-time updates via
/__ws endpoint
Key Types
type Callable = func(*ui.Context) string // All handlers return HTML
type Attr struct { ID, Class, Value, OnClick, OnSubmit, ... } // HTML attributes
Common Imports
import "github.com/michalCapo/g-sui/ui"
Development Commands
go run examples/main.go # Run example app
go test ./... # Run all tests
go test ./ui/... # Test UI package
go build # Build project
1---2name: g-sui-23description: Server-rendered Go UI framework. Use when building g-sui applications, creating UI components, handling forms with server actions, using data tables, setting up routes, or implementing WebSocket patches. Triggered by "g-sui", "server-rendered UI", "Go UI framework", form handling, or data collation.4---56# g-sui Framework78Server-rendered UI framework for Go. All HTML generation, business logic, and state management occur on the server. Interactivity achieved through server actions and WebSocket patches.910## Quick Start1112```go13package main1415import "github.com/michalCapo/g-sui/ui"1617func main() {18 app := ui.MakeApp("en")1920 app.Page("/", func(ctx *ui.Context) string {21 return app.HTML("Home", "bg-gray-100",22 ui.Div("p-8")(23 ui.Div("text-2xl font-bold")("Hello World"),24 ),25 )26 })2728 app.Listen(":8080")29}30```3132## Documentation Index3334| Topic | File | Description |35|-------|------|-------------|36| Core Concepts | [CORE.md](CORE.md) | Architecture, Context, Actions, Targets, server rendering |37| UI Components | [COMPONENTS.md](COMPONENTS.md) | Buttons, inputs, forms, tables, alerts, cards, tabs, etc. |38| Data Management | [DATA.md](DATA.md) | Data collation, search, sort, filter, pagination, Excel export |39| Server Setup | [SERVER.md](SERVER.md) | App initialization, routes, WebSocket, PWA, assets |40| Best Practices | [PATTERNS.md](PATTERNS.md) | Testing, validation, security, state management |4142## Core Philosophy43441. **Server-Centric Rendering** - All HTML generated server-side as strings452. **String-Based Components** - Components are Go functions returning HTML strings463. **Action-Based Interactivity** - User interactions trigger server handlers returning HTML474. **WebSocket-Enhanced** - Real-time updates via `/__ws` endpoint4849## Key Types5051```go52type Callable = func(*ui.Context) string // All handlers return HTML53type Attr struct { ID, Class, Value, OnClick, OnSubmit, ... } // HTML attributes54```5556## Common Imports5758```go59import "github.com/michalCapo/g-sui/ui"60```6162## Development Commands6364```bash65go run examples/main.go # Run example app66go test ./... # Run all tests67go test ./ui/... # Test UI package68go build # Build project69```