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
-
Native. Real computer program (binary executable): not a "web page".
-
Cross platform. macOS/Windows/Linux(Wayland/X11)/iOS/Android.
-
No boilerplate setup. Start writing application code right away.
-
Declarative / Immediate. Describe what the UI should look like. No need to
create or manage "widget" objects or retain their states in your code.
Suitable for complex and fluid UIs with no book-keeping for widget states.
-
Flexbox-like layout. Containers arrange items horizontally or vertically,
with options for padding, gaps, alignment, wrapping, floating, scrolling, and
size expansion.
-
Robust text support. Bidirectional layout, shaping, IME, system fonts,
inline text styling.
-
Audio output. Low-level sample streams that works on all platforms.
-
Platform Layer Access. extension packages can support platform features
that are not included in Shirei itself.
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.
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
-
No builtin method to produce 'release' bundles.
- We do have a
mobilerun utility to run in development mode on mobile phones.
-
Text blocks with large buffer will kill responsiveness! Use the LargeText
instead, which uses a virtual list with each line as a row.
-
No "theme" system, but custom widgets are easy to create, and even duplicate
the behavior of the default provided widgets by reusing their core function.
The following items are out of scope and will not be supported, at least for the time being: