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 navigationScrollView- Scrollable view for pre-wrapped linesStatusBar- Left/center/right status bar with hintsTextInput- Single-line text input with cursorTreeView- Hierarchical tree view with selectionModal- Overlay with dimmed background
§Styling
All components use unified styling objects:
SelectListStyle- Styling for SelectList (base, selection, scrollbar)ScrollViewStyle- Styling for ScrollView (base, scrollbar)StatusBarStyle- Styling for StatusBar (base, hints, separators)TextInputStyle- Styling for TextInput (base, placeholder, cursor)TreeViewStyle- Styling for TreeView (base, selection, branches)ModalStyle- Styling for Modal (base, dimming)
Common types are available in the style module.
§Example
ⓘ
use tui_dispatch_components::{
Line, SelectList, SelectListBehavior, SelectListProps, SelectListStyle,
};
// 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: |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§
Structs§
- Line
- A line of text, consisting of one or more
Spans. - Lines
Scroller - Simple wrapper for rendering pre-rendered lines in a ScrollView
- Modal
- Modal overlay component
- Modal
Behavior - Behavior configuration for Modal
- Modal
Props - Props for Modal component
- Modal
Style - Configuration for modal appearance
- Modifier
- Modifier changes the way a piece of text is displayed.
- Scroll
View - A scrollable viewport container
- Scroll
View Behavior - Behavior configuration for ScrollView
- Scroll
View Props - Props for ScrollView component
- Scroll
View Style - Unified styling for ScrollView
- Select
List - A scrollable selection list with keyboard navigation
- Select
List Behavior - Behavior configuration for SelectList
- Select
List Props - Props for SelectList component
- Select
List Style - Unified styling for SelectList
- Status
Bar - A status bar with left/center/right sections
- Status
BarHint - A single hint entry (key + label)
- Status
BarProps - Props for StatusBar component
- Status
BarSection - Section configuration for the status bar
- Status
BarStyle - Unified styling for StatusBar
- Style
- Style lets you control the main characteristics of the displayed elements.
- Text
Input - A single-line text input with cursor
- Text
Input Props - Props for TextInput component
- Text
Input Style - Unified styling for TextInput
- Tree
Branch Style - Visual style for tree branches
- Tree
Node - Tree node data structure
- Tree
Node Render - Context for custom node rendering
- Tree
View - Tree view component with selection and expand/collapse
- Tree
View Behavior - Behavior configuration for TreeView
- Tree
View Props - Props for TreeView component
- Tree
View Style - Unified styling for TreeView
- Visible
Range - Information about the visible range for content rendering
Enums§
- Color
- ANSI Color
- Status
BarItem - An item within a status bar section
- Tree
Branch Mode - Branch connector rendering mode
Functions§
- centered_
rect - Calculate a centered rectangle within an area