ratatui-toolkit

A comprehensive collection of reusable TUI components for ratatui, the Rust terminal UI library.
Features
| Component | Description |
|---|---|
| ResizableSplit | Draggable split panels (vertical/horizontal) with mouse support |
| TreeView | Generic tree widget with expand/collapse, navigation, and selection |
| FileSystemTree | File browser with devicons and sorting |
| MarkdownRenderer | Render markdown to styled ratatui Text |
| Toast | Toast notifications with auto-expiry and severity levels |
| Dialog | Modal dialogs (Info/Success/Warning/Error/Confirm) |
| Button | Clickable buttons with hover states |
| ClickableScrollbar | Scrollbar with drag and click support |
| HotkeyFooter | Keyboard shortcut display footer |
| HotkeyModal | Help overlay for key bindings |
| MenuBar | Horizontal menu bar with icons |
| StatusBar | Customizable status bar |
| StatusLineStacked | Neovim-style powerline status |
| MasterLayout | Application shell with tabs, panes, vim-like navigation |
| TermTui | Terminal emulator with mprocs-style copy mode |
| AlacTerm | Alacritty-based embedded terminal |
| VT100Term | VT100 terminal emulator with scrollback |
| FuzzyFinder | PTY-based fuzzy search popup |
Installation
Add to your Cargo.toml:
[]
= "0.1"
Or with specific features:
[]
= { = "0.1", = false, = ["tree", "split", "toast"] }
Feature Flags
| Feature | Default | Description |
|---|---|---|
markdown |
✅ | Markdown rendering to ratatui Text |
tree |
✅ | Generic tree view widget |
dialog |
✅ | Modal dialog components |
toast |
✅ | Toast notification system |
split |
✅ | Resizable split panels |
menu |
✅ | Menu bar component |
statusbar |
✅ | Status bar components |
hotkey |
✅ | Hotkey footer and modal |
terminal |
✅ | Terminal emulators (TermTui, AlacTerm, VT100) |
fuzzy |
❌ | Fuzzy finder component |
master-layout |
❌ | Full application layout framework |
file-tree |
❌ | File system tree with devicons |
full |
❌ | Enable all features |
Quick Start
use *;
use *;
// Create a resizable split
let split = new
.ratio
.min_ratio
.max_ratio;
// Create a toast notification
let toast = new
.level
.duration;
// Render markdown
let text = render_markdown;
Examples
Run examples with:
Resizable Split
use ;
let mut split = new
.ratio
.min_ratio
.max_ratio;
// Handle mouse events
if let Some = split.handle_mouse
// Render
let = split.split;
frame.render_widget;
frame.render_widget;
Tree View
use ;
// Build tree structure
let root = new
.with_children;
let mut state = new;
let tree = new;
// Handle navigation
state.handle_key; // Move down
state.handle_key; // Expand
state.handle_key; // Collapse
Toast Notifications
use ;
use Duration;
let mut manager = new
.max_toasts
.default_duration;
// Add toasts
manager.push;
manager.push;
manager.push;
manager.push;
// Update and render
manager.tick; // Remove expired toasts
render_toasts;
Markdown Rendering
use ;
// Simple rendering
let text = render_markdown;
// Custom styling
let style = default
.heading_color
.code_bg;
let text = render_markdown_with_style;
// Render to frame
frame.render_widget;
Terminal Emulator (TermTui)
use ;
// Spawn a terminal with default shell
let shell = var.unwrap_or;
let mut term = spawn_with_command?;
// Handle input
term.handle_key;
term.handle_mouse;
// Render
term.render;
Default Keybindings:
Ctrl+X- Enter copy modeCtrl+Shift+C- Copy selection
Copy Mode:
h/j/k/lor arrows - NavigatevorSpace- Start selectionyorEnter- Copy and exitw/b- Word navigation0/$- Line start/endg/G- Top/bottomEscorq- Exit copy mode
Customizable Keybindings
All interactive components expose their keybindings through configuration structs, allowing full customization:
TermTui
use ;
use ;
// Create custom keybindings
let mut bindings = default;
bindings.enter_copy_mode = new;
let term = spawn_with_command?
.with_keybindings;
TreeView
use ;
use KeyCode;
let bindings = new
.with_next
.with_previous
.with_expand
.with_collapse;
let navigator = with_keybindings;
MasterLayout
use ;
use KeyCode;
let mut bindings = default;
bindings.navigate_left = Char;
bindings.navigate_right = Char;
let layout = new
.with_keybindings;
Available Keybinding Configs
| Component | Config Struct | Builder Method |
|---|---|---|
| TermTui | TermTuiKeyBindings |
.with_keybindings() |
| VT100Term | VT100TermKeyBindings |
.with_keybindings() |
| AlacTerm | AlacTermKeyBindings |
.with_keybindings() |
| TreeView | TreeKeyBindings |
TreeNavigator::with_keybindings() |
| MasterLayout | MasterLayoutKeyBindings |
.with_keybindings() |
Architecture
Component Pattern
All components follow ratatui's Widget and StatefulWidget patterns:
// Stateless widget
// Stateful widget
Mouse Support
Components support mouse interaction through a consistent API:
// Handle mouse events
if let Some = component.handle_mouse
Comparison with Alternatives
| Crate | Focus | Components |
|---|---|---|
| ratatui-toolkit | Comprehensive component library | 17+ components |
tui-textarea |
Text editing | Textarea only |
tui-tree-widget |
Tree views | Tree only |
ratatui-image |
Image rendering | Images only |
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
Licensed under the MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT).