TUI components for Bubble Tea 🫧
Go to file
2022-01-10 13:37:34 -05:00
.github/workflows Update linter config 2021-07-12 03:10:31 +02:00
help Add simple helper package for making user-definable keymappings and help bubble 2021-08-23 17:00:29 +02:00
key key.Matches now accepts multiple binding arguments 2022-01-10 12:32:37 -05:00
list Add list bubble 2021-08-23 21:34:13 +02:00
paginator Add list bubble 2021-08-23 21:34:13 +02:00
progress Progress bars now statisfy the tea.Model interface 2021-09-07 13:57:46 -04:00
spinner Fix typo in a spinner comment 2021-06-02 10:49:43 -04:00
stopwatch Expose stopwatch StartStopMsg and ResetMsg and bind them to IDs 2022-01-10 13:37:34 -05:00
textinput Ensure that textinputs can only receive their own blink messages 2021-06-02 10:49:43 -04:00
timer feat: simple timer component (#67) 2021-09-09 15:17:33 -04:00
viewport Fix bug where performance rendering could render one line too many 2021-09-17 16:25:25 -04:00
.gitignore Initial commit. Add .gitignore 2020-01-18 10:56:08 -05:00
.golangci.yml Update linter config 2021-07-12 03:10:31 +02:00
bubbles.go Rename to Bubbles + copy over components from Bubble Tea + remove examples 2020-05-25 20:08:37 -04:00
go.mod Bump bubbletea, lipgloss, reflow, termenv deps 2021-08-23 21:45:01 +02:00
go.sum Bump bubbletea, lipgloss, reflow, termenv deps 2021-08-23 21:45:01 +02:00
LICENSE Add README and LICENSE 2020-01-27 21:29:52 -05:00
README.md Fixed typo in README ("complimented" → "complemented") 2021-12-09 09:58:11 +01:00

Bubbles

The Bubbles Logo

Latest Release GoDoc Build Status Go ReportCard

Some components for Bubble Tea applications. These components are used in production in Glow, Charm and many other applications.

Spinner

Spinner Example

A spinner, useful for indicating that some kind an operation is happening. There are a couple default ones, but you can also pass your own ”frames.”

Text Input

Text Input Example

A text input field, akin to an <input type="text"> in HTML. Supports unicode, pasting, in-place scrolling when the value exceeds the width of the element and the common, and many customization options.

Progress

Progressbar Example

A simple, customizable progress meter, with optional animation via Harmonica. Supports solid and gradient fills. The empty and filled runes can be set to whatever you'd like. The percentage readout is customizable and can also be omitted entirely.

Paginator

Paginator Example

A component for handling pagination logic and optionally drawing pagination UI. Supports "dot-style" pagination (similar to what you might see on iOS) and numeric page numbering, but you could also just use this component for the logic and visualize pagination however you like.

Viewport

Viewport Example

A viewport for vertically scrolling content. Optionally includes standard pager keybindings and mouse wheel support. A high performance mode is available for applications which make use of the alternate screen buffer.

This component is well complemented with Reflow for ANSI-aware indenting and text wrapping.

List

List Example

A customizable, batteries-included component for browsing a set of items. Features pagination, fuzzy filtering, auto-generated help, an activity spinner, and status messages, all of which can be enabled and disabled as needed. Extrapolated from Glow.

Help

Help Example

A customizable horizontal mini help view that automatically generates itself from your keybindings. It features single and multi-line modes, which the user can optionally toggle between. It will truncate gracefully if the terminal is too wide for the content.

Key

A non-visual component for managing keybindings. Its useful for allowing users to remap keybindings as well as generating help views corresponding to your keybindings.

type KeyMap struct {
    Up key.Binding
    Down key.Binding
}

var DefaultKeyMap = KeyMap{
    Up: key.NewBinding(
        key.WithKeys("k", "up"),        // actual keybindings
        key.WithHelp("↑/k", "move up"), // corresponding help text
    ),
    Down: key.NewBinding(
        WithKeys("j", "down"),
        WithHelp("↓/j", "move down"),
    ),
}

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    switch msg := msg.(type) {
    case tea.KeyMsg:
        switch {
        case key.Matches(msg, DefaultKeyMap.Up):
            // The user pressed up
        case key.Matches(msg, DefaultKeyMap.Down):
            // The user pressed down
        }
    }
    return m, nil
}

Additional Bubbles

  • promptkit: A collection of common prompts for cases like selection, text input, and confirmation. Each prompt comes with sensible defaults, remappable keybindings, any many customization options.
  • mritd/bubbles: Some general-purpose bubbles. Inputs with validation, menu selection, a modified progressbar, and so on.

If youve built a Bubble you think should be listed here, let us know.

License

MIT


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source