SUPERLIGHTTUI(1)

NAME

SuperLightTUI β€” πŸ¦€ An immediate-mode Rust TUI framework with flexbox layout and Tailwind-style chaining API.

SYNOPSIS

INFO

148 stars
5 forks
0 views

DESCRIPTION

πŸ¦€ An immediate-mode Rust TUI framework with flexbox layout and Tailwind-style chaining API.

README

SuperLightTUI

Superfast to write. Superlight to run.

Crate Badge Docs Badge CI Badge MSRV Badge Downloads Badge License Badge

Docs Index Β· Quick Start Β· Widget Guide Β· Patterns Guide Β· Examples Guide Β· Backends Guide Β· Architecture Guide

English Β· δΈ­ζ–‡ Β· EspaΓ±ol Β· ζ—₯本θͺž Β· ν•œκ΅­μ–΄

SuperLightTUI is an immediate-mode TUI library for Rust with a deliberately small public grammar. You write one closure, SLT calls it every frame, and the library handles layout, focus, diffing, and rendering.

It is designed for fast product iteration, approachable Rust syntax, and serious backend discipline. That makes it work equally well for humans prototyping a tool and for coding agents generating UI from docs.

Showcase

Widget Demo
Widget Demo
cargo run --example demo
Dashboard
Dashboard
cargo run --example demo_dashboard
Website
Website Layout
cargo run --example demo_website
Spreadsheet
Spreadsheet
cargo run --example demo_spreadsheet
Games
Games
cargo run --example demo_game
DOOM Fire
DOOM Fire Effect
cargo run --release --example demo_fire

Quick Start

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

5 lines. No App trait. No Model/Update/View. No manual event loop. Ctrl+C just works.

60-Second Grammar

There are four ideas most apps start with:

  1. State lives in normal Rust variables or structs.
  2. Layout is mostly row(), col(), and container().
  3. Styling is method chaining.
  4. Interactive widgets usually return Response.
ui.bordered(Border::Rounded).title("Status").p(1).gap(1).col(|ui| {
    ui.text("SLT").bold().fg(Color::Cyan);
    ui.row(|ui| {
        ui.text("mode:");
        ui.text("ready").fg(Color::Green);
        ui.spacer();
        if ui.button("Quit").clicked {
            ui.quit();
        }
    });
});

That is the core mental model. Everything else is depth, not a second framework.

A Real App

use slt::{Border, Color, Context, KeyCode};

fn main() -> std::io::Result<()> { let mut count: i32 = 0;

slt::run(|ui: &amp;mut Context| {
    if ui.key(&#39;q&#39;) {
        ui.quit();
    }
    if ui.key(&#39;k&#39;) || ui.key_code(KeyCode::Up) {
        count += 1;
    }
    if ui.key(&#39;j&#39;) || ui.key_code(KeyCode::Down) {
        count -= 1;
    }

    ui.bordered(Border::Rounded).title(&quot;Counter&quot;).p(1).gap(1).col(|ui| {
        ui.text(&quot;Counter&quot;).bold().fg(Color::Cyan);
        ui.row(|ui| {
            ui.text(&quot;Count:&quot;);
            let color = if count &gt;= 0 { Color::Green } else { Color::Red };
            ui.text(format!(&quot;{count}&quot;)).bold().fg(color);
        });
        ui.text(&quot;k +1 / j -1 / q quit&quot;).dim();
    });
})

}

Why SLT

  • Small public grammar. Most screens start with normal Rust state, row() / col() / container(), method chaining, and Response.
  • Less framework ceremony. Many apps do not need an app trait, retained tree, or message enum just to get moving.
  • Batteries included, backend still serious. Common widgets auto-wire focus, hover, click, and scroll behavior, while the runtime keeps a conservative low-level path through Backend, AppState, and frame().
  • Conservative internals. SLT keeps the public surface small, but the internals stay deliberately boring: shared frame kernel, explicit backend contract coverage, zero unsafe, feature-gated runtime paths, and validation across all-features, no-default-features, WASM, clippy, examples, cargo-hack, semver, and deny checks.

For Rust users, that usually means less setup than retained-mode TUI frameworks. For AI-assisted workflows, it means the public grammar is easy to infer from docs and examples.

SLT fits best when you want to build terminal apps quickly without giving up Rust type safety or backend escape hatches. If you want a retained component tree or a GUI-first toolkit, another library may be a better fit.

Common API Surface

// Text and layout
ui.text("Hello").bold().fg(Color::Cyan);
ui.row(|ui| {
    ui.text("left");
    ui.spacer();
    ui.text("right");
});

// Inputs and actions ui.text_input(&mut name); if ui.button("Save").clicked {} ui.checkbox("Dark mode", &mut dark);

// Data and navigation ui.tabs(&mut tabs); ui.list(&mut items); ui.table(&mut data); ui.command_palette(&mut palette);

// Overlays and rich output ui.toast(&mut toasts); ui.modal(|ui| { ui.text("Confirm?").bold(); }); ui.markdown("# Hello world");

// Visualization ui.chart(|c| { c.line(&data); c.grid(true); }, 50, 16); ui.sparkline(&values, 16); ui.canvas(40, 10, |cv| { cv.circle(20, 20, 15); });

For the categorized widget list, see Widget Guide. For composition advice, see Patterns Guide.

Learn The Library

DocumentWhat it covers
Quick StartInstall, first app, closure mental model, layout, widget state
Widget GuideComplete API catalog of widgets, runtime methods, and state types
Patterns GuideState placement, screen composition, helper extraction, large-app structure
Examples GuideRunnable examples grouped by product shape and feature area
Backends GuideBackend, AppState, frame(), inline mode, static output
Testing GuideTestBackend, EventBuilder, multi-frame tests, backend contract tests
Debugging GuideF12 overlay, clipping, focus surprises, previous-frame behavior
AI GuideFastest path for AI-assisted builders and coding agents
Architecture GuideModule map, frame lifecycle, layout/render pipeline
Features GuideFeature flags, optional dependencies, recommended combos
Animation GuideTween, spring, keyframes, sequence, stagger
Theming GuideTheme struct, presets, ThemeBuilder, custom themes
Design PrinciplesAPI constraints and design philosophy

Representative Examples

ExampleCommandFocus
hellocargo run --example helloSmallest possible app
countercargo run --example counterState + keyboard input
democargo run --example demoBroad widget tour
demo_dashboardcargo run --example demo_dashboardDashboard layout
demo_clicargo run --example demo_cliCLI tool layout
demo_infovizcargo run --example demo_infovizCharts and data viz
demo_gamecargo run --example demo_gameImmediate-mode interaction
inlinecargo run --example inlineInline rendering below a normal prompt
async_democargo run --example async_demo --features asyncBackground messages

The full categorized index lives in Examples Guide.

Custom Widgets And Backends

  • Implement Widget when you want reusable high-level building blocks.
  • Implement Backend and drive frame() when you want a non-terminal target, external event loop, or embedded runtime.
  • Use TestBackend for headless rendering checks and stable interaction tests.

The public grammar stays small even when you need the escape hatches.

Contributing

Read Contributing, then Design Principles and Architecture Guide. The release process expects format, check, clippy, tests, examples, and backend gates to stay green.

License

MIT

SEE ALSO

clihub3/25/2026SUPERLIGHTTUI(1)