Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Ratatui Kit
Terminal UI. Composed.
Build with components. Think in state. A Rust terminal UI framework built on Ratatui and Tokio.
Documentation · Quick Start · Components · Examples · Ecosystem · 简体中文
Overview
Ratatui Kit adds components, props, hooks, routing, input layers, and theming to Rust terminal applications. Ratatui draws the interface. Tokio drives async work. The framework manages component lifetimes, retained state, and reactive rendering.
- Describe the interface with
#[component]andelement!. Compose layouts and embed native Ratatui widgets. - Organize state with hooks for local state, futures, and effects. Opt into atoms for shared state.
- Build the application with routes, isolated input layers, and palettes that coordinate the whole interface.
The pixel terminal assembler reflects Ratatui’s terminal culture and this framework’s component layer. See the brand assets for the character source and usage guidelines.
See it running
The website includes real terminal recordings with playback controls. Clone this repository to run the same examples locally:
| Example | Run command | Walkthrough |
|---|---|---|
| Task management | cargo run --example todo_app |
Task management |
| Mouse interaction | cargo run --example mouse |
Mouse interaction |
| Data tables | cargo run --example table |
Data tables |
| Routing | cargo run --example router |
Routing |
- Features
- Quick start
- Built-in components and hooks
- Feature flags
- Documentation and examples
- Ecosystem
- Design goals
- Contributing
- License
Features
- Declarative components: write terminal UI trees with
element!, including first-classif,if let,for, andmatchcontrol flow inside child blocks. - React-style hooks: use local state, futures, effects, memoized values, context, terminal size, lifecycle cleanup, and input handlers in component functions.
- State retention by identity: the runtime reuses component instances across frames using
ElementKey + TypeId, preserving hook slots and local state when identity stays stable. - Waker-driven rendering: state writes wake the render loop instead of requiring manual redraw calls.
- Async-native runtime: the terminal loop runs on Tokio, so components can spawn futures and react to async work naturally.
- Flex-style layout:
LayoutStylemaps common layout concepts (flex_direction,justify_content,gap,margin,offset,width,height) to Ratatui layout primitives. - Unified theming: a shared
Paletteis the single color source, and every component derives its styles from it via a per-componentFooTheme. Recolor globally withPaletteProvider, override one component type withThemeOverride, or drive the palette from anAtomto re-theme at runtime. - Central input routing:
InputRuntime,InputLayer,EventScope,EventPriority, andEventResultmake modals and edit modes block background shortcuts cleanly. - Local and global state: use component-local
State<T>for local lifetimes andAtom<T>for process-wide shared state. - Built-in router:
RouterProvider,Outlet,routes!,use_navigate,use_route, anduse_paramsare available behind therouterfeature. - Native widget escape hatch: use
widget(expr)andstateful(widget, state)to embed existing Ratatui widgets directly. - Small default dependency surface: the default feature set is empty; opt into
router,atom,input,tree,table,virtual-list,serde, orfullas needed. The theming protocol is always-on with no extra dependency.
Quick start
Install the crate:
Or let Cargo add the full feature set:
This writes a dependency entry like:
[]
= { = "...", = ["full"] }
= { = "1", = ["rt-multi-thread", "macros", "time"] }
The default feature set is intentionally empty. Enable only the capabilities you need, or use full for examples and prototypes.
Counter example
use ;
async
Run the example from this repository:
AI-assisted development
Ratatui Kit ships an AI agent skill — a packaged knowledge base that teaches your AI coding assistant the framework's real components, props, and hooks, the element! macro, input layers, and the router — so you can ask it to "build me a terminal todo app" and get code that compiles and follows the framework's idioms, instead of guessed APIs.
The skill lives in skills/ratatui-kit/ and your assistant consults it automatically. Pair it with the general-purpose rust-best-practices and rust-async-patterns skills for Rust-level correctness. See AI-assisted development for the full guide.
Built-in components and hooks
README keeps the API overview intentionally compact. See the documentation site and docs.rs for signatures and deeper examples.
Components
| Component | Purpose | Feature |
|---|---|---|
View, Border, Center, Fragment |
Layout and container primitives | core |
Text, WrappedText |
Text rendering and measured wrapping | core |
Positioned |
Absolute positioning | core |
Modal, ConfirmModal, AlertModal, ShortcutInfoModal |
Modal surfaces with input isolation | core |
Select, MultiSelect |
Single and multiple selection lists | core |
ScrollView |
Scrollable viewport | core |
ContextProvider |
Scoped context injection | core |
PaletteProvider, ThemeOverride |
Theme injection — global palette and per-component overrides | core |
Button |
Mouse action button (left Down) | core |
Input, SearchInput |
Single-line input and search input | input |
TreeSelect |
Tree selection | tree |
Table |
Data-driven table with cell-grid borders, wrapping, responsive columns, footer rows, and row/column highlighting | table |
VirtualList |
Virtualized list rendering | virtual-list |
RouterProvider, Outlet |
Routing container and nested route outlet | router |
You can also bridge any native Ratatui widget with widget(expr) or stateful(widget, state).
Hooks
| Hook | Purpose | Feature |
|---|---|---|
use_state |
Component-local reactive state | core |
use_future, use_async_state |
Async tasks and async state | core |
use_memo, use_effect |
Memoized derived values and side effects | core |
use_context |
Read values from the nearest context provider | core |
use_palette, use_component_theme |
Read the current palette or a resolved component theme | core |
use_click / use_hover / use_drag / use_pointer |
Click, hover, drag, pointer events | core |
use_event_handler |
Register scoped input handlers | core |
use_input_layer |
Create a same-frame input layer handle | core |
use_insert_before, use_terminal_size |
Insert content before render and read terminal size | core |
use_exit, use_on_drop |
Exit the application and run cleanup callbacks | core |
use_navigate, use_route, use_params |
Router navigation and route data | router |
use_atom |
Subscribe to global atoms | atom |
Procedural macros
element! · #[component] · #[derive(Props)] · routes! (router) · #[with_layout_style]
Feature flags
| Feature | Enables | Extra dependencies |
|---|---|---|
default |
Nothing ([]) |
- |
router |
RouterProvider, Outlet, routes!, use_navigate, use_route, use_params |
regex |
atom |
Atom, AtomState, use_atom |
- |
input |
Input, SearchInput, and the tui_input re-export |
tui-input |
tree |
TreeSelect and the tui_tree_widget re-export |
tui-tree-widget |
table |
Table, width-aware wrapping, responsive columns, and grid borders |
unicode-width |
virtual-list |
VirtualList and the tui_widget_list re-export |
tui-widget-list |
serde |
Serialize / Deserialize for Palette |
serde, ratatui/serde |
full |
All optional features above | - |
The textarea feature is currently disabled during the Ratatui 0.30 migration because tui-textarea does not yet provide a compatible release.
Documentation and examples
- Learning path
- Quick start
- Installation and feature flags
- Hooks
- State model
- Theming
- Routing
- Built-in components
- Examples
- Simplified Chinese docs
- DeepWiki
Selected runnable examples:
hello_world counter async_state atom_state
router control_flow input_mutex input
search_input scrollview wrapped_text modal
confirm_modal alert_modal shortcut_info_modal select
multi_select tree_select table virtual_list
virtual_multi_select custom_widget custom_hook custom_provider
todo_app
Some examples require optional features such as input, tree, table, virtual-list, or router. Running examples from this repository uses the workspace configuration and enables full.
Ecosystem
Beyond the built-in components, ratatui-kit has a growing ecosystem of third-party
component crates, published independently as ratatui-kit-<name>. They depend only on the
stable Extension API and do not need to be merged into this repo,
so the core stays small.
- Find components — search the
ratatui-kitkeyword on crates.io, or browse awesome-ratatui-kit. - Write your own — scaffold from the
component template
(
cargo generate yexiyue/ratatui-kit-component-template) and follow the Component Guide. - Official extensions live in
ratatui-kit-contrib (e.g.
ratatui-kit-markdown— Markdown / code-block / diff / blockquote / divider).
Design goals
Ratatui Kit is inspired by React, iocraft, and ink, but stays close to Rust and Ratatui:
- Declarative: describe what the UI should look like instead of mutating terminal buffers by hand.
- Reactive: state changes wake the runtime, and the framework reconciles the component tree for the next frame.
- Async-first: timers, IO, and background tasks fit into component lifetimes through Tokio.
- Composable: the built-in components stay business-neutral; application-specific behavior belongs in your own hooks, providers, and components.
- Escape-friendly: when a native Ratatui widget is the right tool, embed it directly.
Contributing
Issues and pull requests are welcome.
Before sending a PR, run the same validation matrix used by CI:
RUSTDOCFLAGS="-D warnings"
This repository uses lefthook for local pre-commit checks.
License
Ratatui Kit is released under the MIT License.
Mouse interactions: cargo run --example mouse. Enable capture with fullscreen_with(RunOptions { mouse: true }). See Pointer Events.