Skip to content

Router

A QuickGUI UI projection of QuickGUI core routing with nested layouts and bounded memory history.

Loading interactive demo…

#Import

Import ui from github.com/egoist/quickgui/go/ui.

import (
	"github.com/egoist/quickgui/go/ui"
)

#Usage

func RouterExample() *native.Node {
	return ui.Router(ui.RouterProps{
		InitialPath: "/",
		Routes: []*ui.RouteDeclaration{
			ui.Route(
				"/",
				func() *native.Node {
					return ui.Link(
						ui.LinkProps{Href: "/settings"},
						"Settings",
					)
				},
			),
			ui.Route(
				"/settings",
				func() *ui.Element { return ui.Text("Settings") },
			),
		},
		Fallback: func() *ui.Element { return ui.Text("Page not found") },
	})
}

#Anatomy

  • ui.Router
  • ui.Route
  • ui.Layout
  • ui.Link
  • ui.Outlet

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

ui.Router(props RouterProps) *native.Node

Router renders the route table's matched chain. Declarations never change after creation.

Routes[]*RouteDeclaration—

Static route declarations built with `ui.Route` and `ui.Layout`.

[]*RouteDeclaration
View source
InitialPathstring—

Initial destination for the bounded in-memory history.

string
View source
FallbackComponent—

Content rendered when no route matches.

Component
View source