Skip to main content

Crate slt

Crate slt 

Source
Expand description

§SLT — Super Light TUI

Immediate-mode terminal UI for Rust. Two dependencies. Zero unsafe.

SLT gives you an egui-style API for terminals: your closure runs each frame, you describe your UI, and SLT handles layout, diffing, and rendering.

§Quick Start

fn main() -> std::io::Result<()> {
    slt::run(|ui| {
        ui.text("hello, world");
    })
}

§Features

  • Flexbox layoutrow(), col(), gap(), grow()
  • 20+ built-in widgets — input, textarea, table, list, tabs, button, checkbox, toggle, spinner, progress, toast, separator, help bar, scrollable, chart, bar chart, sparkline, histogram, canvas, grid
  • Styling — bold, italic, dim, underline, 256 colors, RGB
  • Mouse — click, hover, drag-to-scroll
  • Focus — automatic Tab/Shift+Tab cycling
  • Theming — dark/light presets or custom
  • Animation — tween and spring primitives with 9 easing functions
  • Inline mode — render below your prompt, no alternate screen
  • Async — optional tokio integration via async feature
  • Layout debugger — F12 to visualize container bounds

§Feature Flags

FlagDescription
asyncEnable run_async() with tokio channel-based message passing
serdeEnable Serialize/Deserialize for Style, Color, Theme, and layout types

Re-exports§

pub use crate::test_utils::EventBuilder;
pub use crate::test_utils::TestBackend;
pub use anim::Keyframes;
pub use anim::LoopMode;
pub use anim::Sequence;
pub use anim::Spring;
pub use anim::Stagger;
pub use anim::Tween;
pub use chart::Axis;
pub use chart::ChartBuilder;
pub use chart::ChartConfig;
pub use chart::ChartRenderer;
pub use chart::Dataset;
pub use chart::DatasetEntry;
pub use chart::GraphType;
pub use chart::HistogramBuilder;
pub use chart::LegendPosition;
pub use chart::Marker;
pub use context::Bar;
pub use context::BarDirection;
pub use context::BarGroup;
pub use context::CanvasContext;
pub use context::Context;
pub use context::Response;
pub use context::Widget;
pub use event::Event;
pub use event::KeyCode;
pub use event::KeyModifiers;
pub use event::MouseButton;
pub use event::MouseEvent;
pub use event::MouseKind;
pub use style::Align;
pub use style::Border;
pub use style::Color;
pub use style::Constraints;
pub use style::Justify;
pub use style::Margin;
pub use style::Modifiers;
pub use style::Padding;
pub use style::Style;
pub use style::Theme;
pub use widgets::ButtonVariant;
pub use widgets::FormField;
pub use widgets::FormState;
pub use widgets::ListState;
pub use widgets::ScrollState;
pub use widgets::SpinnerState;
pub use widgets::TableState;
pub use widgets::TabsState;
pub use widgets::TextInputState;
pub use widgets::TextareaState;
pub use widgets::ToastLevel;
pub use widgets::ToastMessage;
pub use widgets::ToastState;

Modules§

anim
Animation primitives: tweens, springs, keyframes, sequences, and staggers.
buffer
Double-buffer grid of Cells with clip-stack support.
cell
Single terminal cell — the smallest unit of the render buffer.
chart
Data visualization: line charts, scatter plots, bar charts, and histograms.
context
event
Terminal input events.
layout
Flexbox layout engine: builds a tree from commands, computes positions, and renders to a Buffer.
rect
Axis-aligned rectangle type used throughout SLT for layout regions, clipping bounds, and hit-test areas.
style
Visual styling primitives.
test_utils
Headless testing utilities.
widgets
Widget state types passed to Context widget methods.

Structs§

RunConfig
Configuration for a TUI run loop.

Functions§

run
Run the TUI loop with default configuration.
run_inline
Run the TUI in inline mode with default configuration.
run_inline_with
Run the TUI in inline mode with custom configuration.
run_with
Run the TUI loop with custom configuration.