Ratatui Widgets Reference

What each built-in widget does, the builder methods you will use most, and a compiled snippet you can paste into your own draw function.

How Ratatui Widgets Work

Widgets are lightweight values that describe what to draw. You create them inside terminal.draw() on every frame, configure them with builder methods, and render them into a Rect. Stateful widgets keep selection or scroll data in a separate state value owned by your app. The snippets below are bodies of functions with the signature fn ui(frame: &mut Frame, area: Rect) and compile with these imports:

Imports used on this page
use ratatui::layout::{Constraint, Rect};
use ratatui::style::{Color, Style, Stylize};
use ratatui::symbols::Marker;
use ratatui::text::Line;
use ratatui::widgets::canvas::{Canvas, Circle, Rectangle};
use ratatui::widgets::*;
use ratatui::Frame;
Ratatui widget gallery with paragraph, list, table, chart, bar chart, gauge, sparkline, tabs, scrollbar and canvas
Most of the widgets on this page rendered together in one frame.

Block

Container
  • Block::bordered()
  • .title(), .title_bottom()
  • .border_type(BorderType::Rounded)
  • .padding(Padding::uniform(1))

Draws borders, titles and padding around an area. Almost every other widget accepts a block through .block(), so borders and titles look consistent everywhere.

Block example
let block = Block::bordered()
    .border_type(BorderType::Rounded)
    .title(" Settings ")
    .title_bottom(Line::from(" Esc to close ").right_aligned())
    .padding(Padding::horizontal(1));
frame.render_widget(block, area);

Paragraph

Text
  • Paragraph::new(text)
  • .wrap(Wrap { trim: true })
  • .scroll((y, x))
  • .centered(), .right_aligned()

Renders styled Text with alignment, wrapping and scrolling. Use it for help screens, logs, status messages and any block of prose.

Paragraph example
let text = vec![
    Line::from(vec!["Status: ".into(), "online".green().bold()]),
    Line::from("Long lines wrap inside the block when wrapping is enabled."),
];
let paragraph = Paragraph::new(text)
    .wrap(Wrap { trim: true })
    .block(Block::bordered().title(" Info "));
frame.render_widget(paragraph, area);

Table

Collection
  • Table::new(rows, widths)
  • .header(Row)
  • .row_highlight_style()
  • render_stateful_widget + TableState

Displays rows and columns with a header, column constraints and an optional highlighted row. Pair it with TableState for selection and scrolling.

Table example
let rows = [Row::new(["ratatui", "0.30.2"]), Row::new(["crossterm", "0.29.0"])];
let widths = [Constraint::Fill(1), Constraint::Length(8)];
let table = Table::new(rows, widths)
    .header(Row::new(["Crate", "Version"]).bold())
    .row_highlight_style(Style::new().reversed())
    .block(Block::bordered().title(" Dependencies "));
let mut state = TableState::default().with_selected(0);
frame.render_stateful_widget(table, area, &mut state);

List

Collection
  • List::new(items)
  • .highlight_symbol("> ")
  • .highlight_style()
  • ListState::select_next()

A vertical list of items with a highlight symbol for the current selection. Ideal for menus, file pickers and sidebars.

List example
let list = List::new(["Inbox", "Drafts", "Sent"])
    .block(Block::bordered().title(" Mail "))
    .highlight_style(Style::new().black().on_cyan())
    .highlight_symbol("> ");
let mut state = ListState::default().with_selected(Some(0));
frame.render_stateful_widget(list, area, &mut state);

Chart

Data
  • Dataset::default().data(&points)
  • .marker(Marker::Braille)
  • .graph_type(GraphType::Line)
  • Axis::default().bounds([min, max])

Plots one or more datasets as lines or scatter points on numeric axes, with labels and an optional legend.

Chart example
let points = [(0.0, 1.0), (1.0, 3.0), (2.0, 2.0), (3.0, 5.0)];
let dataset = Dataset::default()
    .name("latency")
    .marker(Marker::Braille)
    .graph_type(GraphType::Line)
    .cyan()
    .data(&points);
let chart = Chart::new(vec![dataset])
    .x_axis(Axis::default().bounds([0.0, 3.0]))
    .y_axis(Axis::default().bounds([0.0, 5.0]).labels(["0", "5"]))
    .block(Block::bordered().title(" Latency "));
frame.render_widget(chart, area);

BarChart

Data
  • BarChart::default().data(BarGroup)
  • Bar::default().label().value()
  • .bar_width(), .bar_gap()
  • .direction(Direction::Horizontal)

Draws vertical or horizontal bars, optionally grouped, with labels and values. Good for comparisons across categories.

BarChart example
let bars = [("Mon", 4), ("Tue", 7), ("Wed", 5)]
    .map(|(label, value)| Bar::default().label(label).value(value));
let chart = BarChart::default()
    .data(BarGroup::default().bars(&bars))
    .bar_width(5)
    .bar_gap(1)
    .block(Block::bordered().title(" Deploys "));
frame.render_widget(chart, area);

Gauge

Progress
  • Gauge::default().percent(42)
  • .ratio(0.42)
  • .label("42%")
  • .gauge_style()

A filled bar showing progress as a ratio or percentage with a centered label. LineGauge is a thinner single-line variant.

Gauge example
let gauge = Gauge::default()
    .block(Block::bordered().title(" Download "))
    .gauge_style(Style::new().green().on_black())
    .ratio(0.42)
    .label("42% of 120 MB");
frame.render_widget(gauge, area);

Tabs

Navigation
  • Tabs::new(titles)
  • .select(index)
  • .highlight_style()
  • .divider("|")

A row of titles with one selected tab, used to switch between views. Your app stores the selected index and renders the matching content below.

Tabs example
let tabs = Tabs::new(["Overview", "Logs", "Settings"])
    .select(1)
    .highlight_style(Style::new().yellow().bold())
    .divider("|")
    .block(Block::bordered());
frame.render_widget(tabs, area);

Canvas

Drawing
  • Canvas::default().paint(|ctx| ...)
  • .x_bounds(), .y_bounds()
  • .marker(Marker::Braille)
  • Shapes: Line, Rectangle, Circle, Points

A free-form drawing surface with its own coordinate system. Paint lines, rectangles, circles, points and maps using Braille, block or half-block markers.

Canvas example
let canvas = Canvas::default()
    .block(Block::bordered().title(" Canvas "))
    .marker(Marker::Braille)
    .x_bounds([0.0, 100.0])
    .y_bounds([0.0, 50.0])
    .paint(|ctx| {
        ctx.draw(&Rectangle { x: 10.0, y: 10.0, width: 30.0, height: 20.0, color: Color::Cyan });
        ctx.draw(&Circle { x: 70.0, y: 25.0, radius: 12.0, color: Color::Yellow });
    });
frame.render_widget(canvas, area);

Sparkline

Data
  • Sparkline::default().data(&values)
  • .max(100)
  • .style()
  • .direction(RenderDirection::RightToLeft)

A compact bar-based trend line for a single series, perfect for CPU, request rates or latency history inside small panels.

Sparkline example
let values: Vec<u64> = vec![3, 5, 2, 8, 6, 9, 4, 7];
let sparkline = Sparkline::default()
    .block(Block::bordered().title(" Requests "))
    .data(&values)
    .style(Style::new().magenta());
frame.render_widget(sparkline, area);

Scrollbar

Navigation
  • Scrollbar::new(ScrollbarOrientation::VerticalRight)
  • ScrollbarState::new(len).position(pos)
  • .begin_symbol(), .end_symbol()
  • Render next to a Paragraph or List

Shows the position within scrollable content. It is stateful: ScrollbarState holds the content length and current position, which you update as the user scrolls.

Scrollbar example
let lines: Vec<Line> = (1..=50).map(|i| Line::from(format!("line {i}"))).collect();
let position = 10;
frame.render_widget(Paragraph::new(lines).scroll((position as u16, 0)), area);
let mut state = ScrollbarState::new(50).position(position);
frame.render_stateful_widget(
    Scrollbar::new(ScrollbarOrientation::VerticalRight),
    area,
    &mut state,
);

Beyond the Built-in Widgets

Ratatui also ships LineGauge, Clear (to erase an area before drawing a popup) and a Monthly calendar behind the widget-calendar feature, which is part of the default all-widgets set. When nothing fits, write your own: see how to create custom widgets. The community publishes many more on crates.io, including text inputs, tree views and image renderers; check that a crate supports your Ratatui version before adding it.