Skip to main content

Crate ratatui_core

Crate ratatui_core 

Source
Expand description

ratatui-core is the core library of the ratatui project, providing the essential building blocks for creating rich terminal user interfaces in Rust.

§Why ratatui-core?

The ratatui-core crate is split from the main ratatui crate to offer better stability for widget library authors and advanced integrations. Widget libraries should generally depend on ratatui-core, benefiting from a stable API and reducing the need for frequent updates.

Most applications, on the other hand, should depend on the main ratatui crate, which includes built-in widgets, backend re-exports, and higher-level setup helpers.

In practice:

  • Use ratatui to build applications.
  • Use ratatui-core to implement widgets, backend integrations, or other code that needs the core rendering and layout contracts directly.

§Installation

Add ratatui-core to your Cargo.toml:

cargo add ratatui-core

§Crate Organization

ratatui-core is part of the Ratatui workspace that was modularized in version 0.30.0 to improve compilation times, API stability, and dependency management. This crate provides the foundational types and traits that other crates in the workspace depend on.

When to use ratatui-core:

  • Building widget libraries that implement Widget or StatefulWidget
  • Building custom integrations on top of Ratatui’s core rendering contracts
  • You want minimal dependencies and faster compilation times
  • You need maximum API stability (core types change less frequently)

When to use the main ratatui crate:

  • Building applications
  • You want built-in widgets, backend re-exports, and setup helpers such as ratatui::run

For detailed information about the workspace organization, see ARCHITECTURE.md.

§Features

  • std — enables std
  • layout-cache — enables layout cache; uses thread_local when std is available, critical-section::Mutex otherwise (for no_std/embedded targets).
  • anstyle — enables conversions to / from colors, modifiers, and styles in the [‘anstyle’] crate
  • palette — enables conversions from colors in the palette crate to Color.
  • portable-atomic — enables portable-atomic integration for targets that don’t support atomic types.
  • underline-color — enables the backend code that sets the underline color. Underline color is only supported by the Crossterm backend, and is not supported on Windows 7.
  • scrolling-regions — Use terminal scrolling regions to make some operations less prone to flickering. (i.e. Terminal::insert_before).
  • serde — enables serialization and deserialization of style and color types using the serde crate. This is useful if you want to save themes to a file.

§Contributing

We welcome contributions from the community! Please see our CONTRIBUTING guide for more details on how to get involved.

§License

This project is licensed under the MIT License. See the LICENSE file for details.

Modules§

backend
This module provides the backend implementations for different terminal libraries.
buffer
A module for the Buffer and Cell types.
layout
Layout and positioning in terminal user interfaces.
style
style contains the primitives used to control how your user interface will look.
symbols
Symbols and markers for drawing various widgets.
terminal
Provides the Terminal, Frame, CompletedFrame, and Viewport types.
text
Primitives for styled text.
widgets
The widgets module contains the Widget and StatefulWidget traits, which are used to render UI elements on the screen.

Macros§

assert_buffer_eqDeprecated
Assert that two buffers are equal by comparing their areas and content.