GoFlow supports multiple design systems that allow you to create native-feeling applications across different platforms.
GoFlow provides three approaches to building UI:
- Adaptive Widgets - Automatically switch between design systems based on platform (recommended)
- Material Design - Google's design system (Android, Linux, Windows, Web)
- Cupertino - Apple's design language (iOS, macOS)
Adaptive widgets automatically select the appropriate design system based on the runtime platform:
- iOS/macOS: Uses Cupertino (iOS-style) widgets
- Android/Linux/Windows/Web: Uses Material Design widgets
import "github.com/base-go/GoFlow/pkg/ui/adaptive"
// Create a button that automatically adapts to the platform
button := adaptive.NewButton("Click Me", func() {
fmt.Println("Button clicked!")
})
// Create a card
card := adaptive.NewCard(content)
// Create an app bar
appBar := adaptive.NewAppBar(title)GoFlow automatically detects the platform at runtime:
import "github.com/base-go/GoFlow/pkg/core/framework"
platform := goflow.GetPlatform() // Returns: PlatformAndroid, PlatformIOS, etc.
theme := platform.DefaultTheme() // Returns: "material" or "cupertino"goflow.SetPlatform(goflow.PlatformIOS) // Force iOS style
goflow.SetPlatform(goflow.PlatformAndroid) // Force Material styleMaterial Design is Google's design system, used primarily on Android but also suitable for web and desktop applications.
- Elevation: Shadow-based depth system
- Typography: Roboto font family
- Color System: Primary, accent, and semantic colors
- Angular corners: 4px default border radius
import "github.com/base-go/GoFlow/pkg/ui/material"
// Theme
theme := material.DefaultLightTheme()
darkTheme := material.DefaultDarkTheme()
// Buttons
filledBtn := material.NewButton(child, onPressed)
textBtn := material.NewTextButton("Text", onPressed)
outlinedBtn := material.NewOutlinedButton("Outlined", onPressed)
// Card
card := material.NewCard(content)
// AppBar
appBar := material.NewAppBar(title)
appBar.Leading = backButton
appBar.Actions = []goflow.Widget{actionButton1, actionButton2}type MaterialTheme struct {
// Primary colors
PrimaryColor *goflow.Color // Blue 500
PrimaryDarkColor *goflow.Color // Blue 700
PrimaryLightColor *goflow.Color // Blue 300
AccentColor *goflow.Color // Pink A200
// Background colors
BackgroundColor *goflow.Color // Grey 50
SurfaceColor *goflow.Color // White
ErrorColor *goflow.Color // Red 500
// Text colors
TextPrimaryColor *goflow.Color // Almost Black
TextSecondaryColor *goflow.Color // Grey 600
TextDisabledColor *goflow.Color // Grey 400
}Cupertino is Apple's design language, providing an iOS and macOS native look and feel.
- Blur effects: Translucent backgrounds
- San Francisco font: System font family
- Rounded corners: 10px default border radius
- System colors: Dynamic colors that adapt to light/dark mode
- 44pt touch targets: Minimum size for interactive elements
import "github.com/base-go/GoFlow/pkg/ui/cupertino"
// Theme
theme := cupertino.DefaultLightTheme()
darkTheme := cupertino.DefaultDarkTheme()
// Buttons
filledBtn := cupertino.NewButton(child, onPressed)
textBtn := cupertino.NewTextButton("Text", onPressed)
grayBtn := cupertino.NewGrayButton("Gray", onPressed)
// Card
card := cupertino.NewCard(content)
// NavigationBar
navBar := cupertino.NewNavigationBar(title)
navBar.Leading = backButton
navBar.Trailing = actionButtontype CupertinoTheme struct {
// Primary colors
PrimaryColor *goflow.Color // iOS Blue (#007AFF)
SecondaryColor *goflow.Color // iOS Purple
// Background colors
BackgroundColor *goflow.Color // White
SystemBackgroundColor *goflow.Color // Light Grey
SecondaryBackgroundColor *goflow.Color // White
// Label colors (with opacity support)
LabelColor *goflow.Color // Black
SecondaryLabelColor *goflow.Color // 60% opacity
TertiaryLabelColor *goflow.Color // 30% opacity
// Destructive color
DestructiveColor *goflow.Color // iOS Red (#FF3B30)
}| Platform | GOOS | Default Design System |
|---|---|---|
| Android | android | Material |
| iOS | ios | Cupertino |
| macOS | darwin | Cupertino |
| Linux | linux | Material |
| Windows | windows | Material |
| Web | js | Material |
See examples/adaptive-demo/main.go for a complete example of adaptive widgets.
See examples/material-demo/main.go for Material Design widgets.
See examples/cupertino-demo/main.go for Cupertino widgets.
-
Use Adaptive Widgets: For cross-platform apps, prefer adaptive widgets to automatically match platform conventions.
-
Respect Platform Conventions: When using platform-specific widgets, follow the design guidelines:
- Material: Material Design Guidelines
- Cupertino: Human Interface Guidelines
-
Test on Multiple Platforms: Use
goflow.SetPlatform()to test different design systems during development. -
Custom Styling: You can customize colors and other properties while maintaining the overall design language.
-
Consistency: Stick to one design system per platform for consistency. Don't mix Material and Cupertino in the same app unless intentional.
- Fluent Design (Windows 11)
- Custom theme support
- Theme inheritance and customization
- Dark mode automatic switching
- Accessibility features
- Animation and transitions