statusbar

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 3 Imported by: 0

README

Status Bar

Single-line three-segment status bar.

status-bar preview

Install

glyph add status-bar

This copies status-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 status-bar library to keep in sync.

Hello, world

package main

import (
	"fmt"

	statusbar "github.com/truffle-dev/glyph/components/status-bar"
	"github.com/truffle-dev/glyph/components/theme"
)

func main() {
	bar := statusbar.New(theme.Default).
		WithWidth(80).
		WithLeft(statusbar.Item{Text: "glyph"}).
		WithCenter(statusbar.Item{Text: "main"}).
		WithRight(statusbar.Item{Text: "OK", Style: statusbar.StyleSuccess})
	fmt.Println(bar.View())
}

API surface

Package: statusbar

Types

  • Style
  • Item
  • Bar

Functions and methods

  • New
  • WithWidth
  • WithSeparator
  • WithLeft
  • WithCenter
  • WithRight
  • View

Dependencies

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

Notes

Compose with your main view: lipgloss.JoinVertical(lipgloss.Left, mainView, bar.View()). Item styles available: Default, Primary, Success, Warning, Error, Muted.

See also

License

MIT, same as the rest of glyph.

Documentation

Overview

Package statusbar renders a single-line, three-segment status bar. Items in the left segment fill from the left, items in the right fill from the right, and an optional center segment is placed at the visual center. When width is tight the left segment truncates first so the right segment stays visible.

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 Bubble Tea-compatible status bar. It implements no Update; composition with a parent model is the expected pattern.

func New

func New(t theme.Theme) Bar

New constructs an empty Bar with width 80 and " · " between items.

func (Bar) View

func (b Bar) View() string

View renders the bar as a single line padded to width. The bar has no border; consumers can wrap it with lipgloss themselves.

func (Bar) WithCenter

func (b Bar) WithCenter(items ...Item) Bar

WithCenter sets the center segment.

func (Bar) WithLeft

func (b Bar) WithLeft(items ...Item) Bar

WithLeft sets the left segment. Items appear left-to-right.

func (Bar) WithRight

func (b Bar) WithRight(items ...Item) Bar

WithRight sets the right segment.

func (Bar) WithSeparator

func (b Bar) WithSeparator(s string) Bar

WithSeparator replaces the default " · " between items within a segment.

func (Bar) WithWidth

func (b Bar) WithWidth(w int) Bar

WithWidth sets the total rendered width. Minimum 20.

type Item

type Item struct {
	Text  string
	Style Style
}

Item is one chip in the bar.

type Style

type Style int

Style controls an item's color treatment.

const (
	StyleDefault Style = iota
	StylePrimary
	StyleSuccess
	StyleWarning
	StyleError
	StyleMuted
)

Jump to

Keyboard shortcuts

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