Progress Bars
NewMaxProgressBar, NewSliceProgressBar, NewParallelProgressBar, and NewTransformProgressBar tolerate non-TTY output and report milestones through slog instead of redrawing. Close() stops rendering, erases every row of the bar and releases its terminal resources. Progress bars can share the default output with Input, Password, Dropdown, and Multichoice, including their validation feedback. They do not change terminal input mode, so closing a bar leaves an active prompt’s editing functional.
NewMaxProgressBar
Creates a mutable progress bar with explicit max size. Use this when your total work count is known.

NewSliceProgressBar
Wraps slice iteration and auto-advances progress as items are consumed. Use this for sequential processing loops.
for item, err := range tui.NewSliceProgressBar(ctx, "Items", items) {
if err != nil {
return err
}
_ = item
}NewParallelProgressBar
Processes slice items concurrently and updates one shared progress bar.
Returns the first worker error and cancels remaining work. Returning
tui.ErrSkip is not a failure: the bar advances and the remaining items run.

NewTransformProgressBar
Works like NewParallelProgressBar, and returns what
the callback produced for each item, in the order of the input slice. Returning
tui.ErrSkip leaves the item out of the results and still advances the bar. Any
other error returns no results, including the ones completed before it.
sizes, err := tui.NewTransformProgressBar(ctx, "Sizes", urls, fetchSize,
tui.WithWorkers(8),
)NewFileProgressReader
Wraps a reader and advances progress by bytes read.
Requires size discovery through Stat().Size() or Size() int64.
ctx := context.Background()
if len(os.Args) < 2 {
println("usage: progress-reader <file>")
return
}
f, err := os.Open(os.Args[1])
if err != nil {
panic(err)
}
defer f.Close()
// the reader reports its size via Stat(), and shows rate and estimate
r, err := tui.NewFileProgressReader(ctx, f, "Reading")
if err != nil {
panic(err)
}
defer r.Close()
n, err := io.Copy(io.Discard, r)
if err != nil {
panic(err)
}
println("read bytes:", n)Without a terminal, reads continue normally and progress is logged as
file progress records with read and size in bytes, see
Without a terminal. An empty file logs 100% on EOF; an
early EOF does not report unread bytes as complete.
Without a terminal
When the output is not a terminal, or CI env is set, a bar draws nothing and
logs its progress through slog.Default() at INFO instead. A record is
emitted when the bar reaches a new 10% milestone and includes label,
percent, done and total. Large steps log only the latest milestone
reached, so a single step to the end logs 100% once. An empty bar logs 100%
when it closes; a bar closed early does not report the rest as done. Configure
the default logger to choose the destination and format.
WithFormatRate
Customizes per-second rate formatting.
p, err := tui.NewMaxProgressBar(ctx, "Upload", 100,
tui.WithFormatRate(func(v float64) string {
return fmt.Sprintf("%.1f items", v)
}),
)WithWorkers
Sets worker count for NewParallelProgressBar and NewTransformProgressBar. Value must be greater than zero.
err := tui.NewParallelProgressBar(ctx, "Jobs", jobs, runJob,
tui.WithWorkers(8),
)Appearance
By default, a bar has two rows: the label, the percentage and the bar, and a hint row with the metrics below it.
Download 62% ━━━━━━━━━━━━━━━━━━━╸────────────
62.0 / 100.0 MiB · 6.2 MiB/s · 12s leftOn a terminal without the Unicode glyphs:
Download 62% ===================>------------
62.0 / 100.0 MiB | 6.2 MiB/s | 12s leftThe percentage always takes four columns, so the bar never moves as it
grows. A bar without a total shows — (? in ASCII) instead of a
percentage. The hint row shows the amount, the rate, the time left and, with
the elapsed time enabled, the elapsed time. When the row is too narrow, it
drops whole entries from the end; when even the first entry does not fit,
the hint row goes. A long label is shortened before the bar is. A terminal
too short for both rows gets the compact row. A bar on its own terminal
through WithOutput also keeps a row below them for the cursor, so it needs
three.
The hint row is the Progress.Hint slot. Like a prompt’s key
hint, it receives a list of entries, each with .Left and .Right, such as
6.2 and MiB/s. It does not inherit from Prompt.Hint.
th := theme.New()
th.Progress.Hint = `{{ range . }}[{{ .Left }} {{ .Right }}] {{ end }}`Set it to theme.Hidden to keep only the bar row.
Compact layout
theme.Progress.Compact = true keeps everything on one row,
as earlier versions did, and drops metrics from the end to keep the bar:
Download 62% ━━━━━━━╸──── 6.2 MiB/s · 12s remaining
In the stacked layout, Progress.Frame receives an empty
.Metrics. A custom frame that shows .Metrics after the bar keeps
working once it selects the compact layout:
Progress.Metrics applies to the compact layout only, and
Progress.Hint to the stacked layout only.
Several bars
Every bar registers with the same coordinator, so goroutines can advance their own bars concurrently.
