News GitHub

Practical cross-platform immediate-mode GUI framework for Go

package main

import (
    app "go.hasen.dev/shirei/app"

    . "go.hasen.dev/shirei"
    . "go.hasen.dev/shirei/widgets"
)

func main() {
    app.SetupWindow("Small Demo", 400, 200)
    app.Run(RootView)
}

var name string
var response = "Please give me your name"
var colorBG bool = true

func RootView() {
    ModAttrs(Gap(10), Background(220, 20, 97, 1))
    if colorBG {
        ModAttrs(Background(220, 20, 94, 1))
    }

    Container(Attrs(Pad(20), Gap(10)), func() {
        Label("Name:", FontWeight(WeightBold))
        Container(Attrs(Row, CrossMid, Gap(10)), func() {
            TextInput(&name)
            if Button(SymInfo, "Hello") {
                if name == "" {
                    response = "Uh, sorry who are you again?"
                } else {
                    response = "Well, hello " + name + "!"
                }
            }
        })
        Label(response)
    })

    Container(Attrs(Expand, Row, CrossMid, Pad2(10, 30), Gap(10), Background(0, 0, 98, 1),
        BoxShadow(2), BorderWidth(1), BorderColor(0, 0, 0, 1)), func() {
        ToggleSwitch(&colorBG)
        Label("Subtle Color Background")
    })
}

Shirei is a practical GUI framework to create desktop and mobile applications as native Go programs, not as webpages, while having a high level of flexibility and fluidity!

Native, Cross-Platform, Declarative, Ergonomic, Extensive!

"Shirei" derives from the Japanese spelling of "Simple Layout". ンプル・レイアウト → シレイ

Latest release

» Shirei v0.6 — Mobile Platform Support

Getting Started

Import package name: go.hasen.dev/shirei

Github repo: https://github.com/hasenj/go-shirei

Copy the code sample above to a new file in an empty directory, then run the following to download the dependencies:

❯ go mod init main
❯ go mod tidy
❯ go run .

You can browse the demo directories on the github repo for more examples.

Read the Tutorial →

Core Features

For the full picture — immediate mode concepts, layout mechanics, colors and text styling, interaction, application patterns, and a reference section of common mistakes — see the full tutorial.

Examples

The following example programs ship with Shirei and are useful programs in and of themeselves.

git_history

Commit log and stacked unified diffs, with fast search for logs and diffs.

haystack

Find-in-files, very fast & implemented in pure Go.

process_monitor

A cross-platform task manager: macOS, Linux, Windows.

du

A disk-usage visualizer with a background scan queue.

piano

A playable keyboard with a few synth voices — works well on desktop and mobile (multi-touch).

fontviewer

Quickly visualize all system fonts at a glance. Helps you quickly choose a font.

icons

A filterable gallery of the bundled icon fonts.

see_pprof

Visualizes profiling data from .pprof files in a GUI app; without launching a web server.

see_exe

See which bundled packages are taking space in your statically linked Go executables.

hacker-news-reader

Hacker news feed and comment threads. Powered by the firebase hacker news API.

Each card links to that example's directory on GitHub, with a README and the full source. They live under examples/ in the go-shirei repo and run with go run ./examples/<name> after cloning.

Known Issues & Limitations

The following items are out of scope and will not be supported, at least for the time being: