viewkit

module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT

README

viewkit

GitHub release CI

A small, dependency-light toolkit for building terminal UIs with Bubble Tea / Lip Gloss. It gives you three things:

  1. layout — the Frame render primitive plus structural tools: headers, rules, sections, panels/boxes, sticky footers, a width-clamped scrollable body/viewport, scroll state, responsive height "tiers", and a focus Ring for tab-cycling between panels (Frame, Header, Panel, Section, SplitStickyFooter, ScrollableBody, ScrollState, Tier, Ring, ScreenFrame, TooNarrow, …).
  2. panels — data visualization that renders neutral structs / []float64 into aligned, styled charts: bar, line, candlestick (OHLC), pie/proportion, and ledger, plus small formatting widgets (Meter, Toggle, Flash).
  3. theme — a theme.Theme value (palette + copy) with theme.Default(); install your own with theme.Use to restyle everything.

viewkit depends only on charmbracelet/lipgloss, charmbracelet/x/ansi, and the standard library. The package dependency flows panels → layout → theme.

Install

go get github.com/codyconfer/viewkit@latest
import (
    "github.com/codyconfer/viewkit/layout"
    "github.com/codyconfer/viewkit/panels"
    "github.com/codyconfer/viewkit/theme"
)

Design contract

viewkit is deliberately domain-agnostic: data crosses the boundary as neutral structs (panels.Datum, panels.OHLC, panels.LedgerRow) and formatter callbacks (func(float64) string) — never your application's domain types. A layout.Frame carries the render width and focus state; construct one with layout.NewFrame(width) and pass it to the charts.

frame := layout.NewFrame(80)

// structural layout — methods on the frame
body := frame.Panel("STATUS", frame.Row("tokens", "1.2M"))

// charts — functions that take the frame
chart := panels.Bar(frame, "GPUs", []panels.Datum{
    {Label: "gpu", Value: 12},
    {Label: "cloud", Value: 30},
}, 40, fmtNum, "no data")
Theming

The palette and UI copy are injectable. Build a theme.Theme from theme.Default(), override what you want, and install it once at startup with theme.Use — every panel and layout helper renders from the active theme (theme.Cur()):

th := theme.Default()
th.Accent = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
th.TooNarrowTitle = "SCREEN TOO SMALL"
theme.Use(th)

Structural dimensions (theme.BodyWidth, theme.MinScreenWidth, the height tiers, …) are exported constants — viewkit's layout contract — rather than part of Theme; set per-view width via layout.NewFrame(width).

Status

Early days — the API may still shift before a v1. It was extracted from the goose project, which remains its primary consumer and reference usage.

Development

The module ships its own .golangci.yml. Build, test, vet, and lint with:

go build ./...
go test ./...
go vet ./...
golangci-lint run

License

MIT © Cody Confer

Directories

Path Synopsis
deck module
Package forms provides keys.Action-driven forms and confirm dialogs for viewkit terminal UIs.
Package forms provides keys.Action-driven forms and confirm dialogs for viewkit terminal UIs.
Package keys maps raw input onto semantic actions and footer hint legends for viewkit applications.
Package keys maps raw input onto semantic actions and footer hint legends for viewkit applications.
Package layout provides frame-based structural layout primitives for terminal UIs built with viewkit.
Package layout provides frame-based structural layout primitives for terminal UIs built with viewkit.
Package notify models transient notifications and TTL queues for viewkit applications.
Package notify models transient notifications and TTL queues for viewkit applications.
Package panels renders charts, tables, and small status widgets against a viewkit layout frame.
Package panels renders charts, tables, and small status widgets against a viewkit layout frame.
Package theme manages viewkit's process-global palette, styles, and screen background rendering.
Package theme manages viewkit's process-global palette, styles, and screen background rendering.
Package timefmt formats timestamps as short human-readable relative strings ("just now", "5m ago", "in 2h", "3d ago") for viewkit feeds and item lists.
Package timefmt formats timestamps as short human-readable relative strings ("just now", "5m ago", "in 2h", "3d ago") for viewkit feeds and item lists.

Jump to

Keyboard shortcuts

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