Skip to main content

Crate tui_dispatch_components

Crate tui_dispatch_components 

Source
Expand description

Pre-built UI components for tui-dispatch

This crate provides reusable TUI components that integrate with tui-dispatch patterns. Components implement the Component<A> trait and emit actions via callback functions passed through Props.

§Components

  • SelectList - Scrollable selection list with keyboard navigation
  • ScrollView - Scrollable view for pre-wrapped lines
  • StatusBar - Left/center/right status bar with hints
  • TextInput - Single-line text input with cursor
  • TreeView - Hierarchical tree view with selection
  • Modal - Overlay with dimmed background

§Styling

All components use unified styling objects:

Common types are available in the style module. Routed command name constants are available in the commands module.

§Example

use tui_dispatch_components::{
    Line, SelectList, SelectListBehavior, SelectListProps, SelectListStyle,
};
use std::rc::Rc;

// In your render function:
let items: Vec<Line> = state.items.iter().map(|s| Line::raw(s)).collect();
let render_item = |item: &Line| item.clone();
let mut list = SelectList::default();
list.render(frame, area, SelectListProps {
    items: &items,
    count: items.len(),
    selected: state.selected,
    is_focused: state.focus == Focus::List,
    style: SelectListStyle::default(),
    behavior: SelectListBehavior::default(),
    on_select: Rc::new(|i| Action::Select(i)),
    render_item: &render_item,
});

Re-exports§

pub use style::highlight_substring;
pub use style::BaseStyle;
pub use style::BorderStyle;
pub use style::ComponentStyle;
pub use style::Padding;
pub use style::ScrollbarStyle;
pub use style::SelectionStyle;

Modules§

commands
Shared command names understood by built-in interactive components.
prelude
Prelude for convenient imports
style
Shared styling types for tui-dispatch-components

Structs§

ComponentDebugEntry
Optional component-local state inspection for debug tooling.
ComponentHost
HostedRuntime
Runtime wrapper that keeps ComponentHost area synchronization out of app loops.
Line
A line of text, consisting of one or more Spans.
LinesScroller
Simple wrapper for rendering pre-rendered lines in a ScrollView
Modal
Modal overlay component
ModalBehavior
Behavior configuration for Modal
ModalProps
Props for Modal component
ModalStyle
Configuration for modal appearance
Modifier
Modifier changes the way a piece of text is displayed.
Mounted
Typed handle to a mounted component.
MountedComponentInfo
ScrollView
A scrollable viewport container
ScrollViewBehavior
Behavior configuration for ScrollView
ScrollViewProps
Props for ScrollView component
ScrollViewRenderProps
Render-only props for ScrollView
ScrollViewStyle
Unified styling for ScrollView
SelectList
A scrollable selection list with keyboard navigation
SelectListBehavior
Behavior configuration for SelectList
SelectListProps
Props for SelectList component
SelectListRenderProps
Render-only props for SelectList
SelectListStyle
Unified styling for SelectList
StatusBar
A status bar with left/center/right sections
StatusBarHint
A single hint entry (key + label)
StatusBarProps
Props for StatusBar component
StatusBarSection
Section configuration for the status bar
StatusBarStyle
Unified styling for StatusBar
Style
Style lets you control the main characteristics of the displayed elements.
TextInput
A single-line text input with cursor
TextInputProps
Props for TextInput component
TextInputRenderProps
Render-only props for TextInput
TextInputStyle
Unified styling for TextInput
TreeBranchStyle
Visual style for tree branches
TreeNode
Tree node data structure
TreeNodeRender
Context for custom node rendering
TreeView
Tree view component with selection and expand/collapse
TreeViewBehavior
Behavior configuration for TreeView
TreeViewProps
Props for TreeView component
TreeViewRenderProps
Render-only props for TreeView
TreeViewStyle
Unified styling for TreeView
VisibleRange
Information about the visible range for content rendering

Enums§

Color
ANSI Color
ComponentInput
Routed input delivered to interactive components.
HostLifecycleError
StatusBarItem
An item within a status bar section
TreeBranchMode
Branch connector rendering mode

Traits§

ComponentDebugState
Optional debug surface for interactive components.
InteractiveComponent
Richer component contract used by ComponentHost.
PropsFactory
Factory that builds component props from store state.
RuntimeHostExt
Extension trait for attaching a ComponentHost to a bus-routed runtime.

Functions§

centered_rect
Calculate a centered rectangle within an area

Type Aliases§

ModalCloseCallback
Callback to create an action when the modal should close.
ScrollViewCallback
Callback to create an action when the scroll offset changes.
SelectListCallback
Callback to create an action when the selected index changes.
TextInputCallback
Callback to create an action when text changes or is submitted.
TextInputCursorCallback
Callback to create an action when the cursor moves.
TreeSelectCallback
Callback to create an action when selection changes.
TreeToggleCallback
Callback to create an action when expansion changes.