progressbar

package
v0.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2026 License: MIT Imports: 4 Imported by: 0

README

Progress bar

Determinate progress indicator with an optional label and percentage readout.

progress-bar preview

Install

glyph add progress-bar

This copies progress-bar.go (and its test file) into your repo at the path your glyph.json aliases declare. After install, the file is yours: edit it, refactor it, rename it. There is no progress-bar library to keep in sync.

Hello, world

package main

import (
	"fmt"

	progressbar "github.com/truffle-dev/glyph/components/progress-bar"
	"github.com/truffle-dev/glyph/components/theme"
)

func main() {
	bar := progressbar.New(theme.Default).
		WithPercent(0.42).
		WithLabel("uploading").
		WithWidth(40)
	fmt.Println(bar.View())
}

API surface

Package: progressbar

API surface inferred from source — see pkg.go.dev.

Dependencies

  • glyph component theme (installed automatically)
  • github.com/charmbracelet/lipgloss@v1.1.0

Notes

Pure render: call WithPercent(0..1) and View(). No internal tick. Drive percent from your model's Update on whatever signal feeds it (HTTP progress, job step counter, file write offset).

See also

License

MIT, same as the rest of glyph.

Documentation

Overview

Package progressbar renders a determinate progress indicator with an optional label, percentage readout, and color-tunable fill.

Progress bars are pure render: the caller updates Percent() and the bar redraws. There is no internal animation or tick; pair with the spinner component if you need an indeterminate indicator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

type Bar struct {
	// contains filtered or unexported fields
}

Bar is a determinate progress indicator.

func New

func New(t theme.Theme) Bar

New constructs a Bar using the theme's Primary color for the fill.

func (Bar) Percent

func (b Bar) Percent() float64

Percent returns the current fill ratio.

func (Bar) View

func (b Bar) View() string

View renders the bar.

func (Bar) WithFillColor

func (b Bar) WithFillColor(c lipgloss.Color) Bar

WithFillColor overrides the fill color. Useful for status bars where you want a Success/Warning/Error-tinted progress strip.

func (Bar) WithLabel

func (b Bar) WithLabel(label string) Bar

WithLabel sets text rendered before the bar. Pass "" to omit.

func (Bar) WithPercent

func (b Bar) WithPercent(p float64) Bar

WithPercent sets the fill ratio. Values are clamped into [0, 1].

func (Bar) WithPercentDisplay

func (b Bar) WithPercentDisplay(show bool) Bar

WithPercent display toggle. Default is on.

func (Bar) WithRunes

func (b Bar) WithRunes(fill, empty string) Bar

WithRunes overrides the fill and empty glyphs. Defaults to block ░ and █.

func (Bar) WithWidth

func (b Bar) WithWidth(w int) Bar

WithWidth sets the bar width in cells (excluding label/percentage). Minimum 1.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL