Skip to content
Maxence Charriere edited this page Dec 6, 2016 · 37 revisions

app

Package to build multiplatform apps with Go, HTML and CSS.

How it works?

app

Component

A component is a struct that represents a graphic element. It implements the app.Componer interface.

type Componer interface {
	Render() string
}

The Render method returns an HTML markup that describes the graphic interface. Components are displayed by being mounted into contexts.

See how to implement a component.

Context

Contexts are application elements which display graphical user interface. They can be a window, a menu, a dock, etc...

They implement the interface app.Contexter which defines their available interactions.

Example

// Component.
type Hello struct {
}

func (h *Hello) Render() string {
	return `<div>Hello World</div>`
}

// Create a window and mounts the Hello Component.
func main() {
	app.OnLaunch = func() {
		win := app.NewWindow(app.Window{
			Title:          "Hello World",
			Width:          1280,
			Height:         720,
		})

		hello := &Hello{}
		win.Mount(hello)
	}

	app.Run()
}
Clone this wiki locally