Overlay container with title, body, footer, and a configurable close key.
glyph add modalThis copies modal.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 modal library to keep in sync.
package main
import (
"fmt"
"github.com/truffle-dev/glyph/components/modal"
"github.com/truffle-dev/glyph/components/theme"
)
func main() {
m := modal.New(theme.Default).
WithTitle("Unsaved changes").
WithBody("You have uncommitted edits. Save before quitting?").
WithFooter("Enter to save · Esc to cancel").
WithSize(48, 8)
fmt.Println(m.View())
}Package: modal
Types
CloseMsgModal
Functions and methods
NewWithTitleWithBodyWithSizeWithCloseKeyWithFooterWidthHeightContentWidthContentHeightInitUpdateView
- glyph component
theme(installed automatically) github.com/charmbracelet/bubbletea@v1.3.10github.com/charmbracelet/lipgloss@v1.1.0
Render m.View() into a string, then lipgloss.Place(parentW, parentH, lipgloss.Center, lipgloss.Center, m.View(), lipgloss.WithWhitespaceChars(" ")) over your background. The modal emits modal.CloseMsg on Esc by default.
- examples/showcase — single-binary TUI composing the seven main surfaces
- components/modal/story — runnable story binary (
go run -tags glyph_story ./components/modal/story/) - registry manifest — the JSON contract
glyph addreads
MIT, same as the rest of glyph.
