bubbles library TUI

Reusable interactive components for Artisanal TUI.

This library provides a collection of widgets (Bubbles) like text inputs, viewports, progress bars, and spinners that can be composed into larger applications.

Available Widgets

Usage

Bubbles can be composed within your own models using ComponentHost:

class MyModel with ComponentHost implements Model {
  final TextInputModel input;
  final SpinnerModel spinner;

  MyModel({
    TextInputModel? input,
    SpinnerModel? spinner,
  }) : input = input ?? TextInputModel(),
       spinner = spinner ?? SpinnerModel();

  @override
  (Model, Cmd?) update(Msg msg) {
    // Delegate to child bubbles
    final (newInput, inputCmd) = updateComponent(input, msg);
    return (
      MyModel(input: newInput, spinner: spinner),
      inputCmd,
    );
  }

  @override
  String view() => '${spinner.view()} ${input.view()}';
}

Display Components

In addition to interactive models, Artisanal provides DisplayComponents. These are simple string renderers that don't handle input but provide consistent styling for tables, lists, and panels.

Use RenderConfig to adapt these components to the current terminal width and color capabilities.

Bubbles can be composed within your own models using ComponentHost:

class MyModel with ComponentHost implements Model {
  final TextInputModel input;
  final SpinnerModel spinner;

  MyModel({
    TextInputModel? input,
    SpinnerModel? spinner,
  }) : input = input ?? TextInputModel(),
       spinner = spinner ?? SpinnerModel();

  @override
  (Model, Cmd?) update(Msg msg) {
    // Delegate to child bubbles
    final (newInput, inputCmd) = updateComponent(input, msg);
    return (
      MyModel(input: newInput, spinner: spinner),
      inputCmd,
    );
  }

  @override
  String view() => '${spinner.view()} ${input.view()}';
}

In addition to interactive models, Artisanal provides DisplayComponents. These are simple string renderers that don't handle input but provide consistent styling for tables, lists, and panels.

Use RenderConfig to adapt these components to the current terminal width and color capabilities.

Classes

Alert
A fluent builder for creating styled alerts.
AlertComponent
An alert/notice block component.
AnticipateConfig
Configuration for anticipate/autocomplete component.
AnticipateKeyMap
Key map for anticipate navigation and selection.
AnticipateModel
Anticipate model for autocomplete input.
Box
A boxed message component.
BoxBuilder
A fluent builder for creating styled boxes.
BulletList
A bullet list component.
Column
Table column definition.
ColumnComponent
A component that renders with a newline after each child.
ColumnsComponent
A multi-column layout component.
Comment
A fluent builder for creating styled comments.
CommentComponent
A comment component (dimmed text with // prefix).
CommonKeyBindings
Commonly used key bindings for navigation.
ComponentBoxChars
Box drawing characters for component system.
CompositeComponent
A component that composes multiple child components.
ConditionalStep
Conditional wizard step.
ConfirmCancelledMsg
Message sent when confirmation is cancelled.
ConfirmKeyMap
Key bindings for the confirm component.
ConfirmModel
A confirmation (yes/no) component following the Model architecture.
ConfirmResultMsg
Message sent when confirmation is made.
ConfirmStep
Confirmation wizard step.
ConfirmStyles
Styles for the confirm component.
CountdownModel
A countdown model built on top of TimerModel.
CursorBlinkMsg
Message indicating the cursor should toggle its blink state.
CursorModel
A blinking cursor widget for text input components.
DebugOverlayModel
Draggable render-metrics overlay for debugging TUI performance.
DefaultItemDelegate
Default item delegate with simple rendering.
DefinitionList
A fluent builder for creating styled definition lists.
DefinitionListComponent
A definition list component (term: description pairs).
DestructiveConfirmModel
A destructive confirmation component that requires typing to confirm.
DisplayComponent
Base type for display-only UI building blocks.
ExceptionComponent
An exception renderer component.
FileEntry
A file entry with cached stat information.
FilePickerErrorMsg
Error message when reading a directory fails.
FilePickerKeyMap
Key mappings for the file picker component.
FilePickerModel
A file picker model for navigating and selecting files.
FilePickerReadDirMsg
Message sent when directory contents are read.
FilePickerStyles
Styles for the file picker component.
FilteredItem
Filtered item with match information.
FilteredSearchItem<T>
A filtered item with its original index and match positions.
FilterMatchesMsg
Filter matches message.
GroupedDefinitionList
A fluent builder for creating grouped definition lists.
GroupStep
Group of wizard steps.
GutterContext
GutterContext provides context to a GutterFunc.
Help
Help information for a key binding.
HelpModel
A help view widget for displaying key bindings.
HelpStyles
Styles for the help view.
HighlightInfo
HorizontalTableComponent
A horizontal table component (row-as-headers style).
ItemDelegate
Item delegate for rendering list items.
KeyBinding
A key binding that maps keys to actions with optional help text.
KeyMap
A collection of key bindings forming a key map.
KeyValue
A key-value pair component with dot fill.
LineInfo
LinkComponent
A clickable hyperlink component (OSC 8).
LinkGroupComponent
A group of related links component.
ListEnumerator
Defines how list items are explicitly enumerated.
ListItem
Item interface for list items.
ListKeyMap
Key map for list navigation.
ListModel
List model for interactive lists.
ListStyles
Styles for list rendering.
MultiProgressModel
A model for managing multiple progress bars simultaneously.
MultiSelectionMadeMsg<T>
Message sent when multiple items are selected.
MultiSelectKeyMap
Key bindings for the multi-select component.
MultiSelectModel<T>
A multi-select component following the Model architecture.
MultiSelectStep
Multi-select wizard step.
MultiSelectStyles
Styles for the multi-select component.
NumberedList
A numbered list component.
PaginatorKeyMap
Key bindings for paginator navigation.
PaginatorModel
A paginator widget for handling pagination state and rendering.
Panel
A fluent builder for creating styled panels.
PanelBoxChars
Box drawing characters for panels and borders.
PanelBoxCharSet
A set of box drawing characters.
PanelComponent
A boxed panel component with optional title.
PasswordCancelledMsg
Message sent when password input is cancelled.
PasswordConfirmModel
A password confirmation component that asks for password twice.
PasswordKeyMap
Key bindings for the password component.
PasswordModel
A password input component following the Model architecture.
PasswordStep
Password input wizard step.
PasswordStyles
Styles for the password component.
PasswordSubmittedMsg
Message sent when password input is submitted.
PasteErrorMsg
Message for paste errors.
PasteMsg
Message for paste events.
PauseModel
A simple "press any key" pause model.
ProgressBar
A progress indicator component.
ProgressBarAdvanceMsg
ProgressBarComponent TUI
A progress bar component.
ProgressBarIterateDoneMsg
ProgressBarIterateErrorMsg
ProgressBarModel
A UV-safe progress bar model that can be hosted inside a parent Model.
ProgressBarMsg
ProgressBarSetMsg
ProgressFrameMsg
Message indicating a progress bar animation frame should advance.
ProgressModel
A progress bar widget with optional animation support.
Rank
Rank from filtering.
RenderConfig TUI
Rendering configuration for display-only UI building blocks.
RowComponent
A component that renders children horizontally with a separator.
Rule
A horizontal rule/separator component.
ScrollbarChars
SearchCancelledMsg
Message sent when search is cancelled.
SearchKeyMap
Key bindings for the search component.
SearchModel<T>
A search/filter component following the Model architecture.
SearchSelectionMadeMsg<T>
Message sent when a search result is selected.
SearchStyles
Styles for the search component.
SelectionCancelledMsg
Message sent when selection is cancelled.
SelectionMadeMsg<T>
Message sent when an item is selected.
SelectKeyMap
Key bindings for the select component.
SelectModel<T>
A single-select component following the Model architecture.
SelectStep
Single-select wizard step.
SelectStyles
Styles for the select component.
SimpleExceptionComponent
A simple one-line exception component.
Spinner
A spinner animation definition.
SpinnerFrame
A spinner frame component (for use in animations).
SpinnerModel
A spinner widget for showing loading/activity states.
Spinners
Pre-defined spinner animations.
SpinnerTickMsg
Message indicating a spinner should advance to the next frame.
StatusMessageTimeoutMsg
Status message timeout message.
StopwatchModel
A stopwatch model that counts up from zero.
StopwatchResetMsg
Message sent to reset the stopwatch.
StopwatchStartStopMsg
Message sent to start or stop the stopwatch.
StopwatchTickMsg
Message sent when the stopwatch ticks.
StringItem
Simple string item implementation.
StyledBlock
A fluent builder for creating styled blocks (Symfony-style).
StyledBlockComponent
A styled block component (Symfony-style).
StyledText
A styled text component using the context's style.
Table
A fluent builder for creating styled tables.
TableComponent
A table component with headers and rows.
TableKeyMap
Key map for table navigation.
TableModel
Table model for interactive tables.
TableStyles
Styles for table rendering.
TaskComponent
A task status component (Laravel-style).
Text
A simple text component.
TextAreaCursorStyle
TextAreaKeyMap
TextAreaModel
TextAreaPasteErrorMsg
TextAreaPasteMsg
TextAreaStyles
TextAreaStyleState
TextInputCursorStyle
Style for the cursor.
TextInputKeyMap
Key map for text input navigation and editing.
TextInputModel
Text input model for single-line text entry.
TextInputStep
Text input wizard step.
TextInputStyles
Styles for the text input.
TextInputStyleState
Style state for focused and blurred states.
TextModel
A high-level text component that supports selection, scrolling, and wrapping. It is built on top of ViewportModel but defaults to auto-height and soft-wrap.
TimerModel
A countdown timer model.
TimerStartStopMsg
Message sent to start or stop the timer.
TimerTickMsg
Message sent when the timer ticks.
TimerTimeoutMsg
Internal message sent when timer times out.
TitledBlockComponent
A simple titled block used by the artisanal-style I/O facade.
Tree
A fluent builder for creating styled trees (lipgloss v2 parity).
TreeChildren
TreeComponent
A tree structure component.
TreeEnumerator
Defines the characters used to draw tree branches.
TreeFilter
TreeNode
TreeNodeChildren
TreeStringData
TwoColumnDetail
A fluent builder for creating two-column detail rows.
TwoColumnDetailComponent
A two-column detail component with dot fill.
TwoColumnDetailList
A fluent builder for creating multiple two-column detail rows.
ViewportKeyMap
Key bindings for viewport navigation.
ViewportModel
A viewport widget for scrollable content.
ViewportScrollPane
WizardCancelledMsg
Message sent when the wizard is cancelled.
WizardCompletedMsg
Message sent when the entire wizard is completed.
WizardModel
Wizard model for multi-step forms.
WizardStep
Base class for wizard steps.
WizardStepCompletedMsg
Message sent when a wizard step is completed.

Enums

AlertDisplayStyle
Alert display style.
AlertType
Alert types.
BlockStyleType
Block style types.
BorderStyle
Border styles for boxes.
BoxAlign
Alignment for box content.
ConfirmDisplayMode
Display mode for the confirm component.
CursorMode
Cursor display mode.
EchoMode
Echo mode for text input display.
FilterState
Filter state for the list.
PaginationType
Pagination rendering type.
PanelAlignment
Alignment for panel content.
PasswordEchoMode
Echo mode for password display.
StyledBlockDisplayStyle
Display style for styled blocks.
TaskStatus
Task status values.

Extensions

AlertFactory on Alert
Factory methods for common alert styles.
BoxPresets on BoxBuilder
Factory methods for common box styles.
DefinitionListFactory on DefinitionList
Factory methods for common definition list styles.
KeyMatchExtension on Key
Extension to check key matches more fluently.
KeyMsgMatchExtension on KeyMsg
Extension to check KeyMsg matches.
PanelPresets on Panel
Factory methods for common panel styles.
StyledBlockFactory on StyledBlock
Factory methods for common styled block styles.
TableFactory on Table
Factory methods for common table styles.
TreeFactory on Tree
Factory methods for common tree styles.
TwoColumnDetailFactory on TwoColumnDetail
Factory methods for common two-column detail styles.

Constants

defaultEmptyCharBlock → const String
Default character used to fill the empty portion of the progress bar.
defaultFullCharFullBlock → const String
Default character used to fill the progress bar (full block).
defaultFullCharHalfBlock → const String
Default character used to fill the progress bar. It is a half block, which allows more granular color blending control.
promptProgramOptions → const ProgramOptions
Shared defaults for "artisanal-style" prompts that run a single bubble and return a value.
textareaPromptOptions → const ProgramOptions
Dedicated defaults for full-screen text editing prompts.
undefined → const Object

Functions

defaultFilter(String term, List<String> targets) List<Rank>
Default fuzzy filter implementation.
defaultSearchFilter<T>(String query, List<T> items, String toString(T)) List<FilteredSearchItem<T>>
Default fuzzy filter implementation.
defaultTextAreaStyles() TextAreaStyles
defaultTextInputStyles({bool isDark = true}) TextInputStyles
Returns the default styles for the text input.
keyMatches(Key key, List<KeyBinding> bindings) bool
Checks if a key message matches any of the given bindings.
keyMatchesSingle(Key key, KeyBinding binding) bool
Checks if a key matches a single binding.
mathMax(int a, int b) int
progressIterateCmd<T>({required int id, required Iterable<T> items, required Future<void> onItem(T item)}) StreamCmd<Msg>
Produces a UV-safe StreamCmd that runs onItem for each element and emits progress updates for a hosted ProgressBarModel.
runAnticipatePrompt(AnticipateModel model, Terminal terminal, {ProgramOptions? options}) Future<String?>
Runs an AnticipateModel and resolves to the accepted value, or null if cancelled.
runConfirmPrompt(ConfirmModel model, Terminal terminal, {ProgramOptions? options}) Future<bool?>
Runs a ConfirmModel and resolves to the selected value, or null if cancelled.
runMultiSelectPrompt<T>(MultiSelectModel<T> model, Terminal terminal, {ProgramOptions? options}) Future<List<T>?>
Runs a MultiSelectModel and resolves to the selected items, or null if cancelled.
runPasswordConfirmPrompt(PasswordConfirmModel model, Terminal terminal, {ProgramOptions? options}) Future<String?>
Runs a PasswordConfirmModel and resolves to the submitted password, or null if cancelled.
runPasswordPrompt(PasswordModel model, Terminal terminal, {ProgramOptions? options}) Future<String?>
Runs a PasswordModel and resolves to the submitted password, or null if cancelled.
runSearchPrompt<T>(SearchModel<T> model, Terminal terminal, {ProgramOptions? options}) Future<T?>
Runs a SearchModel and resolves to the selected item, or null if cancelled.
runSelectPrompt<T>(SelectModel<T> model, Terminal terminal, {ProgramOptions? options}) Future<T?>
Runs a SelectModel and resolves to the selected item, or null if cancelled.
runSpinnerTask<T>({required String message, required Future<T> task(), Spinner spinner = Spinners.miniDot, required Terminal terminal, ProgramOptions? options}) Future<T>
Runs an animated spinner while executing task, returning its result.
runTextAreaPrompt(TextAreaModel model, Terminal terminal, {ProgramOptions? options}) Future<String?>
Runs a TextAreaModel and resolves to the submitted value, or null if cancelled.
runTextInputPrompt(TextInputModel model, Terminal terminal, {ProgramOptions? options}) Future<String?>
Runs a TextInputModel and resolves to the submitted value, or null if cancelled.
runWizardPrompt(WizardModel model, Terminal terminal, {ProgramOptions? options}) Future<Map<String, dynamic>?>
Runs a WizardModel and resolves to the final answers, or null if cancelled.

Typedefs

AlertStyleFunc = Style? Function(String line, int lineIndex)
Callback for alert message styling.
BoxContentStyleFunc = Style? Function(String line, int lineIndex)
Callback for box content styling.
ColorFunc = Color Function(double total, double current)
Function that can be used to dynamically fill the progress bar. total is the total filled percentage, and current is the current percentage that is actively being filled with a color.
DefinitionStyleFunc = Style? Function(String term, String description, int index, bool isTerm)
Callback for styling definition list items.
FilterFunc = List<Rank> Function(String term, List<String> targets)
Filter function type.
GutterFunc = String Function(GutterContext context)
GutterFunc can be implemented and set into ViewportModel.leftGutterFunc.
ListStyleFunc = Style? Function(int index, String item)
Callback for per-item styling in lists.
PanelContentStyleFunc = Style? Function(String line, int lineIndex)
Callback for panel content styling.
PromptFunc = String Function(PromptInfo info)
PromptInfo = ({int col, bool isFocused, int lineIndex, int row})
Row = List<String>
Table row (list of cell values).
SearchFilterFunc<T> = List<FilteredSearchItem<T>> Function(String query, List<T> items, String toString(T))
Filter function type for search.
StyledBlockStyleFunc = Style? Function(String line, int lineIndex)
Callback for block content styling.
TableStyleFunc = Style? Function(int row, int col, String data)
Callback for per-cell styling in tables.
TreeEnumeratorFunc = String Function(List<TreeNode> children, int index)
TreeEnumeratorStyleFunc = Style? Function(List children, int index)
Callback for per-item enumerator (branch character) styling in trees.
TreeIndenterFunc = String Function(List<TreeNode> children, int index)
TreeNodeStyleFunc = Style Function(List<TreeNode> children, int index)
TreeStyleFunc = Style? Function(String item, int depth, bool isDirectory)
Callback for per-item styling in trees.
TwoColumnStyleFunc = Style? Function(String text, bool isLeft)
Callback for styling the left or right column.
ValidateFunc = String? Function(String value)
Validation function that returns an error message if input is invalid.