Skip to content
프로젝트

소개

Go 기반 GUI 프레임워크입니다. 실용적인 즉시 모드 방식이며 Flexbox 레이아웃 모델을 사용합니다.

기타 프로젝트

이 수치를 측정하는 방법

What you can do

  • Produce small native binaries, ≈10MB is typical for binary size.
  • Performance and resource usage is a first class design consideration.
  • Easy to learn API & fast iteration cycle for both humans and AI.
  • Simpler UI code, focus on program data, not widget objects.

측정된 스타 증가

in 24h
+1
in 7 days
+4
in 15 days
+29
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Shirei

Shirei is a cross-platform GUI framework for Go, designed as a lightweight alternative to web-based approaches, with a focus on development ergonomics.

  • Build the UI in pure Go, instead of HTML and Javascript
  • Describe the UI as a function of state, instead of creating and maintaining widget objects
  • Arrange a uniform container tree with rows, columns, wrapping, and content-based sizing
  • Custom components can retain internal state that the caller does not have to care about
Profile form with name and email fields and a Save button
func ProfileForm(profile *Profile) {
    Container(Attrs(Expand, Pad(18), Gap(8)), func() {
        Label("Profile", FontSize(22),
            FontWeight(WeightBold))

        Label("Name")
        TextInput(&profile.Name)

        Label("Email")
        TextInput(&profile.Email)

        Container(Attrs(Row, CrossMid, Gap(10)), func() {
            if Button(SymITick, "Save") {
                profile.Saved = true
            }
            if profile.Saved {
                Label("All changes saved",
                    FontSize(12),
                    TextColor(145, 55, 34, 1))
            }
        })
    })
}

Suitable for a wide range of utility applications.

If you find yourself resorting to TUI frameworks because you dread using Electron, give Shirei a try.

※ "Shirei" is derived from the Japanese pronunciation of "Simple Layout": シンプル・レイアウト → シレイ

Shirei supports all major platforms:

  • Windows
  • macOS
  • Linux (Wayland; X11 is a secondary backend)
  • iOS (iPhone)
  • Android

See the changelog for release features and upgrade notes.

We have several example programs in this repo. Some screenshots compare light mode on the left with dark mode on the right:

Git History: quickly verify commit history (linearly)

Git History commit list and unified diff split diagonally between light and dark modes

Haystack: fast "find in files" with tabbed editing and saving

Haystack search results split diagonally between light and dark modes

Piano: simple keyboard piano

Piano keyboard and voice controls

Process Monitor: quickly check how running processes are using CPU/RAM

Process Monitor table and history charts split diagonally between light and dark modes

Run an example with go run . from its directory.

We ship shirei_mobilerun to quickly run apps on Mobile phones.

We also ship shirei_bundle to manage creating release bundles for all supported target platforms.

Cross compilation works for desktop platforms without CGO, including macOS. iOS still requires cgo.

Motivation

There are several approaches to creating UIs, and it has been this author's consistent experience that immediate mode provides the most flexibility and power for the least effort, compared to other approaches.

When we say "immediate mode", we're not talking about the rendering mechanism, rather we are talking about the API: do you "retain" widgets in your application code, or do you just say what the UI should look like right now, given application state?

Existing GUI frameworks in Go all seem to require you to retain widgets yourself, even ones that say they are immediate mode.

Shirei combines two powerful ideas:

  • Build the UI using regular code constructs, and respond to input without callbacks
  • Size containers from their contents and distribute available space along rows and columns

Why use Shirei:

  • Produce small native binaries, ≈10MB is typical for binary size.

  • Performance and resource usage is a first class design consideration.

  • Easy to learn API & fast iteration cycle for both humans and AI.

  • Simpler UI code, focus on program data, not widget objects.

  • Content-based layout with explicit control over remaining space, cross-axis expansion, and scrollable viewports.

  • Batteries included: default widgets, robust text editing, virtual lists, tables, modals.

  • Document editing: TextDocument and TextEditor provide virtualized multiline editing, selection, undo/redo, line numbers, and IME composition. editorfile supplies loading, conflict checks, and saving.

  • Native auxiliary windows on macOS, Windows, Wayland, and X11, with independent input, rendering, transparency, decorations, and owned lifetimes. See the popup demo and window extension.

  • Transparent, draggable desktop overlays on macOS, Windows, and Wayland with layer-shell v4. Background mode keeps the app running when its main window closes; window.Activate restores it from another window or goroutine on these three backends.

  • International text support: unlike what you might expect from imgui libraries from C/C++, Shirei supports complex text shaping and bidirectional layout, input method editor (IME) for East Asian languages, and ability to use all system fonts. Furigana adds readings above Japanese text; labels and editable fields preserve annotation groups through selection, copying, and undo.

  • Snapshot testing: render the normal application frame to an image without opening a native window or requiring a GPU. Headless snapshots always use the software renderer.

  • GPU compositor by default on macOS (Metal), iOS (Metal), Wayland (GLES), Android (GLES), Windows (D3D11), and web (WebGL2). X11 stays software. SHIREI_GPU=0 or init failure falls back to the software renderer.

  • Video playback (go.hasen.dev/shirei/media) and external GPU textures (UseExternalImage) on macOS, iOS, Windows, Linux, and Android, composited in the same pass as UI widgets so translucent controls hover above video. See examples/video_player.

  • Access attributes on containers (NextAccessName, AssignAccess) build a queryable tree each frame. Drive tests launch the app and click by name over loopback UDP: docs/drive-tutorial.md. Command list: docs/drive.md.

Limitations

  • Wayland overlays and explicit window positioning require layer-shell v4. Ordinary windows follow compositor placement, sizing, and focus policies. Cross-monitor overlay dragging changes outputs after release. See Wayland window controls.
  • X11 supports auxiliary windows but lacks background main-window restoration and always-on-top overlay behavior.
  • Basic screen-reader support on macOS, Linux Wayland and 64-bit Windows covers static text, buttons, toggles and sliders; see accessibility for scope and testing
  • Video playback (shirei/media) and external GPU textures (UseExternalImage) are not yet supported on Web (Wasm); see docs/video.md for the platform codec support matrix

Getting started

Copy this into main.go in a new folder:

package main

import (
	"fmt"

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

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

func main() {
	app.SetupWindow("My App", 300, 100)
	app.Run(RootView)
}

var count int

func RootView() {
	Container(Attrs(Viewport, Background(220, 10, 97, 1)), func() {
		Container(Attrs(Row, CrossMid, Pad(20), Gap(10)), func() {
			Label(fmt.Sprintf("Counter: %d", count))
			if Button(SymIPlus, "Increment") {
				count++
			}
		})
	})
}

Then type:

$ go mod init main
$ go mod tidy
$ go run .

You should see a window like this:

Counter window with an Increment button

Tools

Install the companion CLIs (puts binaries on $(go env GOPATH)/bin — keep that on your PATH):

go install go.hasen.dev/shirei/cmd/shirei_mobilerun@latest
go install go.hasen.dev/shirei/cmd/shirei_bundle@latest
Command Role
shirei_mobilerun Dev installs on iOS / Android (debug signing, fast iteration)
shirei_bundle Release packaging (IPA, release APK, macOS zip/pkg, desktop archives)

Learn

관련 프로젝트 살펴보기

불러오는 중…