ratatui
Skill1 starsChanged 4 months agoMITView on GitHub
ratatui is a crate for cooking up terminal user interfaces in Rust. A library that's all about cooking up terminal user interfaces.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- a-poor/skillstheir own version, first seen Aug 20, 2026
- FlorianBruniaux/ccboardtheir own version, first seen Apr 29, 2026
- ZhangHanDong/ratatui-skillstheir own version, first seen Jan 19, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- FlorianBruniaux/ccboard★ 96same name
- ZhangHanDong/ratatui-skills★ 4same name
- a-poor/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- notifySkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Add ratatui and crossterm as dependencies to your cargo.toml:
- Very specific: line 42
Use run() for normal applications.
- Very specific: line 43
Use init() / restore() (or try_init() / try_restore()) when you want manual control over terminal lifetime and the event loop structure.
- Very specific: line 44
Use init_with_options() / try_init_with_options() when you need a custom Viewport, such as inline rendering or a fixed drawing region.
- Very specific: line 76
Every application built with ratatui needs to implement the following steps:
- Very specific: line 129
Use run() as the default. Reach for init() / restore() when setup and teardown should surround code outside the application closure, and …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Ratatui Website · API Docs · Examples · Changelog · Breaking Changes
Quickstart
Add ratatui and crossterm as dependencies to your cargo.toml:
cargo add ratatui crosstermThen you can create a simple “Hello World” application:
use crossterm::event;
fn main() -> std::io::Result<()> {
ratatui::run(|mut terminal| {
loop {
terminal.draw(|frame| frame.render_widget("Hello World!", frame.area()))?;
if event::read()?.is_key_press() {
break Ok(());
}
}
})
}Which setup path should I use?
Most application authors should start with one of these entry points:
- Use
run()for normal applications. It initializes the terminal, runs your app, and restores the terminal on exit. - Use
init()/restore()(ortry_init()/try_restore()) when you want manual control over terminal lifetime and the event loop structure. - Use
init_with_options()/try_init_with_options()when you need a customViewport, such as inline rendering or a fixed drawing region.
Reach for Terminal::new or Terminal::with_options directly only when you need custom backend construction or terminal setup that Ratatui’s convenience functions do not manage.
Which crate should I use?
Most application authors should stay in this ratatui crate. It is the docs.rs entry point for building apps and re-exports the pieces most applications need.
Reach for other crates in the workspace only when you specifically need a lower-level layer:
ratatui-corefor widget libraries, custom integrations, and lower-level rendering contractsratatui-widgetswhen you only need the built-in widgets crate as a dependencyratatui-crossterm,ratatui-termion,ratatui-termina, orratatui-termwizwhen your application needs backend-specific APIs or a direct backend dependency
Crate Organization
Starting with Ratatui 0.30.0, the project was reorganized into a modular workspace to improve compilation times, API stability, and dependency management. Most applications should continue using this main ratatui crate, which re-exports everything for convenience:
ratatui: Main crate with complete functionality (recommended for apps)ratatui-core: Core traits and types for widget librariesratatui-widgets: Built-in widget implementations- Backend crates:
ratatui-crossterm,ratatui-termion,ratatui-termina,ratatui-termwiz ratatui-macros: Macros for simplifying the boilerplate
For application developers: ratatui remains the recommended starting point.
Writing Applications
Ratatui is based on the principle of immediate rendering with intermediate buffers. This means that for each frame, your app must render all widgets that are supposed to be part of the UI. This is in contrast to the retained mode style of rendering where widgets are updated and then automatically redrawn on the next frame. See the Rendering section of the Ratatui Website for more info.
Ratatui uses Crossterm by default as it works on most platforms. See the Installation section of the Ratatui Website for more details on how to use other backends (Termion / Termwiz).
Every application built with ratatui needs to implement the following steps:
- Initialize the terminal (see the
initmodule for convenient initialization functions) - A main loop that:
- Draws the UI
- Handles input events
- Restore the terminal state
Initialize and restore the terminal
The simplest way to initialize and run a terminal application is to use the run() function, which handles terminal initialization, restoration, and panic hooks automatically:
fn main() -> std::io::Result<()> {
ratatui::run(|mut terminal| {
loop {
terminal.draw(render)?;
if should_quit()? {
break Ok(());
}
}
})
}
fn render(frame: &mut ratatui::Frame) {
// ...
}
fn should_quit() -> std::io::Result<bool> {
// ...
}For more control over initialization and restoration, you can use init() and restore():
fn main() -> std::io::Result<()> {
let mut terminal = ratatui::init();
let result = run_app(&mut terminal);
ratatui::restore();
result
}
fn run_app(terminal: &mut ratatui::DefaultTerminal) -> std::io::Result<()> {
loop {
terminal.draw(render)?;
if should_quit()? {
break Ok(());
}
}
}Use run() as the default. Reach for init() / restore() when setup and teardown should surround code outside the application closure, and see the init module documentation for the full chooser including try_* and *_with_options.
Manual Terminal and Backend Construction
Before the convenience functions were introduced in version 0.28.1 (init()/restore()) and 0.30.0 (run()), applications constructed Terminal and Backend instances manually. This approach is still supported for applications that need fine-grained control over initialization, custom backends, or terminal setup that should happen outside Ratatui’s convenience helpers. See the Terminal and backend module documentation for details.
See the backend module and the Backends section of the Ratatui Website for more info on the alternate screen and raw mode. Learn more about different backend options in the Backend Comparison guide.
Drawing the UI
Drawing the UI is done by calling the Terminal::draw method on the terminal instance. This method takes a closure that is called with a Frame instance. The Frame provides the size of the area to draw to and allows the app to render any Widget using the provided render_widget method. After this closure returns, a diff is performed and only the changes are drawn to the terminal. See the Widgets section of the Ratatui Website and the Widget Recipes for more info on creating effective UIs.
The closure passed to the Terminal::draw method should handle the rendering of a full frame. For guidance on setting up the terminal before drawing, see the init module documentation.
use ratatui::Frame;
use ratatui::widgets::Paragraph;
fn run(terminal: &mut ratatui::DefaultTerminal) -> std::io::Result<()> {
loop {
terminal.draw(|frame| render(frame))?;
if handle_events()? {
break Ok(());
}
}
}
fn render(frame: &mut Frame) {
let text = Paragraph::new("Hello World!");
frame.render_widget(text, frame.area());
}What happens if…
- If the terminal is resized:
Ratatui does not redraw automatically when a resize event arrives. Your app should continue the event loop and call
Terminal::drawagain. During that render pass, Ratatui checks the backend’s current size instead of assuming the resize events were complete or up to date. This keeps layout based on the size that actually exists when rendering, even if multiple resize events were coalesced, missed, or delivered before the UI redraws. Fullscreen and inline viewports update their internal size during that render pass; fixed viewports keep their configured rectangle until you callTerminal::resize. - If
Terminal::try_drawreturns an error: The render pass stops early and Ratatui does not promise that the terminal, cursor, and internal buffers are still synchronized. In most applications, return the error and let the surrounding setup path restore terminal state on exit. - If you move the cursor directly:
Cursor changes made through backend-specific APIs or
Terminalcursor methods can be overwritten by the next render pass if that pass sets cursor state throughFrame. Prefer choosing one path and using it consistently. - If you mutate the backend directly: Direct backend changes bypass Ratatui’s diffing and viewport bookkeeping. After doing that, run a full draw pass or clear the terminal before assuming Ratatui’s internal view still matches the screen.
Handling events
Ratatui does not include any input handling. Instead event handling can be implemented by calling backend library methods directly. See the Handling Events section of the Ratatui Website for conceptual information. For example, if you are using Crossterm, you can use the crossterm::event module to handle events.
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
fn handle_events() -> std::io::Result<bool> {
match event::read()? {
Event::Key(key) if key.kind == KeyEventKind::Press => match key.code {
KeyCode::Char('q') => return Ok(true),
// handle other key events
_ => {}
},
// handle other events
_ => {}
}
Ok(false)
}Layout
The library comes with a basic yet useful layout management object called Layout which allows you to split the available space into multiple areas and then render widgets in each area. This lets you describe a responsive terminal UI by nesting layouts. See the Layout section of the Ratatui Website for more info, and check out the Layout Recipes for practical examples.
use ratatui::Frame;
use ratatui::layout::{Constraint, Layout};
use ratatui::widgets::Block;
fn draw(frame: &mut Frame) {
use Constraint::{Fill, Length, Min};
let vertical = Layout::vertical([Length(1), Min(0), Length(1)]);
let [title_area, main_area, status_area] = vertical.areas(frame.area());
let horizontal = Layout::horizontal([Fill(1); 2]);
let [left_area, right_area] = horizontal.areas(main_area);
frame.render_widget(Block::bordered().title("Title Bar"), title_area);
frame.render_widget(Block::bordered().title("Status Bar"), status_area);
frame.render_widget(Block::bordered().title("Left"), left_area);
frame.render_widget(Block::bordered().title("Right"), right_area);
}Running this example produces the following output:
Title Bar───────────────────────────────────
┌Left────────────────┐┌Right───────────────┐
│ ││ │
└────────────────────┘└────────────────────┘
Status Bar──────────────────────────────────Text and styling
The Text, Line and Span types are the building blocks of the library and are used in many places. Text is a list of Lines and a Line is a list of Spans. A Span is a string with a specific style.
The style module provides types that represent the various styling options. The most important one is Style which represents the foreground and background colors and the text attributes of a Span. The style module also provides a Stylize trait that allows short-hand syntax to apply a style to widgets and text. See the Styling Text section of the Ratatui Website for more info, and explore the Styling Recipes for creative examples.
use ratatui::Frame;
use ratatui::layout::{Constraint, Layout};
use ratatui::style::{Color, Modifier, Style, Stylize};
use ratatui::text::{Line, Span};
use ratatui::widgets::{Block, Paragraph};
fn draw(frame: &mut Frame) {
let areas = Layout::vertical([Constraint::Length(1); 4]).split(frame.area());
let line = Line::from(vec![
Span::raw("Hello "),
Span::styled(
"World",
Style::new()
.fg(Color::Green)
.bg(Color::White)
.add_modifier(Modifier::BOLD),
),
"!".red().on_light_yellow().italic(),
]);
frame.render_widget(line, areas[0]);
// using the short-hand syntax and implicit conversions
let paragraph = Paragraph::new("Hello World!".red().on_white().bold());
frame.render_widget(paragraph, areas[1]);
// style the whole widget instead of just the text
let paragraph = Paragraph::new("Hello World!").style(Style::new().red().on_white());
frame.render_widget(paragraph, areas[2]);
// use the simpler short-hand syntax
let paragraph = Paragraph::new("Hello World!").blue().on_yellow();
frame.render_widget(paragraph, areas[3]);
}Features
The crate provides a set of optional features that can be enabled in your Cargo.toml file.
default— By default, we enable the crossterm backend as this is a reasonable choice for most applications as it is supported on Linux/Mac/Windows systems. We also enable theunderline-colorfeature which allows you to set the underline color of text, themacrosfeature which provides some useful macros andlayout-cachewhich speeds up layout cache calculations.
Generally an application will only use one backend, so you should only enable one of the following features:
crossterm(enabled by default) — enables theCrosstermBackendbackend and adds a dependency oncrossterm.crossterm_0_28— selects the crossterm 0.28.x backend implementationcrossterm_0_29— selects the crossterm 0.29.x backend implementation (default)termion— enables theTermionBackendbackend and adds a dependency ontermion.termina— enables theTerminaBackendbackend and adds a dependency ontermina.termwiz— enables theTermwizBackendbackend and adds a dependency ontermwiz.std(enabled by default) — enables std
The following optional features are available for all backends:
serde— enables serialization and deserialization of style and color types using theserdecrate. This is useful if you want to save themes to a file.layout-cache(enabled by default) — enables layout cachepalette— enables conversions from colors in thepalettecrate toColor.portable-atomic— enables portable-atomic integration for targets that don’t support atomic types.scrolling-regions— Use terminal scrolling regions to make some operations less prone to flickering. (i.e. Terminal::insert_before).macros(enabled by default) — enables themacrosmodule which provides some useful macros for creating spans, lines, text, and layoutsall-widgets(enabled by default) — enables all widgets.
Widgets that add dependencies are gated behind feature flags to prevent unused transitive dependencies. The available features are:
widget-calendar(enabled by default) — enables thecalendarwidget module.
The following optional features are only available for some backends:
underline-color(enabled by default) — Enables the backend code that sets the underline color. Underline color is only supported by the Crossterm, Termina, and Termwiz backends, and is not supported on Windows 7.
The following features are unstable and may change in the future:
unstable— Enable all unstable features.unstable-rendered-line-info— Enables theParagraph::line_countParagraph::line_widthmethods which are experimental and may change in the future. See Issue 293 for more details.unstable-widget-ref— enables theWidgetRefandStatefulWidgetReftraits which are experimental and may change in the future.unstable-backend-writer— Enables getting access to backends’ writers.
References
Structs
- CompletedFrame
- Frame
- Terminal
- TerminalOptions
- backend::CrosstermBackend
- backend::TerminaBackend
- backend::TermionBackend
- backend::TermwizBackend
- backend::TestBackend
- backend::WindowSize
- buffer::Buffer
- buffer::BufferDiff
- buffer::Cell
- layout::Columns
- layout::Layout
- layout::Margin
- layout::Offset
- layout::Position
- layout::Positions
- layout::Rect
- layout::Rows
- layout::Size
- prelude::Buffer
- prelude::CrosstermBackend
- prelude::Frame
- prelude::Layout
- prelude::Line
- prelude::Margin
- prelude::Masked
- prelude::Modifier
- prelude::Position
- prelude::Rect
- prelude::Size
- prelude::Span
- prelude::Style
- prelude::TerminaBackend
- prelude::Terminal
- prelude::TermionBackend
- prelude::TermwizBackend
- prelude::Text
- prelude::backend::TestBackend
- prelude::backend::WindowSize
- prelude::buffer::Buffer
- prelude::buffer::BufferDiff
- prelude::buffer::Cell
- prelude::layout::Columns
- prelude::layout::Layout
- prelude::layout::Margin
- prelude::layout::Offset
- prelude::layout::Position
- prelude::layout::Positions
- prelude::layout::Rect
- prelude::layout::Rows
- prelude::layout::Size
- prelude::style::Modifier
- prelude::style::ParseColorError
- prelude::style::Style
- prelude::style::palette::material::AccentedPalette
- prelude::style::palette::material::NonAccentedPalette
- prelude::style::palette::tailwind::Palette
- prelude::symbols::bar::Set
- prelude::symbols::block::Set
- prelude::symbols::border::Set
- prelude::symbols::line::Set
- prelude::symbols::scrollbar::Set
- prelude::text::Line
- prelude::text::Masked
- prelude::text::Span
- prelude::text::StyledGrapheme
- prelude::text::Text
- style::Modifier
- style::ParseColorError
- style::Style
- style::palette::material::AccentedPalette
- style::palette::material::NonAccentedPalette
- style::palette::tailwind::Palette
- symbols::bar::Set
- symbols::block::Set
- symbols::border::Set
- symbols::line::Set
- symbols::scrollbar::Set
- text::Line
- text::Masked
- text::Span
- text::StyledGrapheme
- text::Text
- widgets::Axis
- widgets::Bar
- widgets::BarChart
- widgets::BarGroup
- widgets::Block
- widgets::Borders
- widgets::Cell
- widgets::Chart
- widgets::Clear
- widgets::Dataset
- widgets::Dimmed
- widgets::Fill
- widgets::Gauge
- widgets::LineGauge
- widgets::List
- widgets::ListItem
- widgets::ListState
- widgets::Padding
- widgets::Paragraph
- widgets::RatatuiLogo
- widgets::RatatuiMascot
- widgets::Row
- widgets::Scrollbar
- widgets::ScrollbarState
- widgets::Shadow
- widgets::Sparkline
- widgets::SparklineBar
- widgets::Table
- widgets::TableState
- widgets::Tabs
- widgets::Wrap
- widgets::calendar::CalendarEventStore
- widgets::calendar::Monthly
- widgets::canvas::Canvas
- widgets::canvas::Circle
- widgets::canvas::Context
- widgets::canvas::FilledLine
- widgets::canvas::Label
- widgets::canvas::Line
- widgets::canvas::Map
- widgets::canvas::Painter
- widgets::canvas::Points
- widgets::canvas::Rectangle
Enums
- Viewport
- backend::ClearType
- buffer::CellDiffOption
- layout::Constraint
- layout::Direction
- layout::Flex
- layout::HorizontalAlignment
- layout::Spacing
- layout::VerticalAlignment
- prelude::Color
- prelude::Constraint
- prelude::Direction
- prelude::HorizontalAlignment
- prelude::VerticalAlignment
- prelude::backend::ClearType
- prelude::buffer::CellDiffOption
- prelude::layout::Constraint
- prelude::layout::Direction
- prelude::layout::Flex
- prelude::layout::HorizontalAlignment
- prelude::layout::Spacing
- prelude::layout::VerticalAlignment
- prelude::style::Color
- prelude::symbols::Marker
- prelude::symbols::marker::Marker
- prelude::symbols::merge::MergeStrategy
- style::Color
- symbols::Marker
- symbols::marker::Marker
- symbols::merge::MergeStrategy
- widgets::BorderType
- widgets::GraphType
- widgets::HighlightSpacing
- widgets::LegendPosition
- widgets::ListDirection
- widgets::MascotEyeColor
- widgets::RatatuiLogoSize
- widgets::RenderDirection
- widgets::ScrollDirection
- widgets::ScrollbarOrientation
- widgets::TitlePosition
- widgets::canvas::MapResolution
Macros
- border
Functions
- init
- init::init
- init::init_with_options
- init::restore
- init::run
- init::try_init
- init::try_init_with_options
- init::try_restore
- init_with_options
- restore
- run
- try_init
- try_init_with_options
- try_restore
- widgets::dimmed
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

