English
ProgressBar: progress indicators
Build progress indicators with ProgressBar. This page includes a runnable example, all props, and behavior constraints.
Complete example
Complete environment setup first. Copy this complete main.go and run go run ..
go
package main
import (
"fmt"
"github.com/dxui-org/dxui"
"log"
)
func main() {
value := float32(.25)
app := dxui.NewApp(dxui.AppOptions{
Title: "ProgressBar",
Width: 640,
Height: 480,
Background: dxui.RGBA(248, 250, 252, 255),
})
if err := app.Run(func() dxui.View {
return dxui.Box(
dxui.BoxProps{
Gap: 16,
Style: dxui.Style{
Padding: dxui.Padding(24),
},
},
dxui.Box(
dxui.BoxProps{
Gap: 12,
},
dxui.ProgressBar(dxui.ProgressBarProps{
Value: value,
}),
dxui.TextButton(
dxui.ButtonProps{
OnPress: func() {
value += .1
if value > 1 {
value = 0
}
},
},
"Advance",
),
dxui.Label(fmt.Sprintf("%.0f%%", value*100)),
),
)
}); err != nil {
log.Fatal(err)
}
}Parameters and API
go
func ProgressBar(props ProgressBarProps) View| Field | Type | Purpose, defaults, and constraints |
|---|---|---|
Key | string | Stable unique identity within one parent; empty by default. Use business IDs in dynamic lists, not changing indices. |
Style | Style | Local layout, paint, and text styling; zero uses intrinsic sizes and theme defaults. |
Token | ComponentToken | Component theme entry; empty selects its default. |
States | StateStyles | Paint patches for actual interaction states; cannot fabricate state or change layout. |
Pointer | PointerBehavior | Defaults to PointerAuto; PointerNone excludes the entire subtree from pointer participation, unlike Disabled. |
Value | float32 | Current application-owned value; see this page for its range and zero-value behavior. |
Behavior and limitations
Value is a 0..1 ratio, not a percentage. Out-of-range values clamp; NaN/-Inf are empty and +Inf is full. No events or internal progress timer. Background controls the track; Text.Color controls the fill. Default size is 160×12 with an 8-unit track. No indeterminate, segmented, vertical, or animated modes.
All components share identity, style, and pointer rules. See full declarations for referenced enums, structs, and comments. Running examples explains build verification.