Skip to main content

Crate revue

Crate revue 

Source
Expand description

§Revue

A Vue-style TUI framework for Rust with CSS styling, reactive state management, and a rich set of widgets for building beautiful terminal user interfaces.

§Features

FeatureDescription
CSS StylingExternal CSS files with variables, selectors, transitions, and hot reload
Flexbox LayoutCustom TUI-optimized layout engine for flexible layouts
Reactive StateVue-inspired Signal/Computed/Effect pattern
80+ WidgetsText, Button, Input, Table, Tree, Modal, Toast, Charts, and more
Markdown & ImagesBuilt-in markdown rendering with Kitty image protocol support
Developer ToolsHot reload, widget inspector, snapshot testing (Pilot)
ThemingBuilt-in themes: Dracula, Nord, Monokai, Gruvbox, Catppuccin

§Quick Start

use revue::prelude::*;

fn main() -> Result<()> {
    let mut app = App::builder().build();
    let counter = Counter::new();

    app.run_with_handler(counter, |key, state| {
        state.handle_key(&key.key)
    })
}

struct Counter { value: i32 }

impl Counter {
    fn new() -> Self { Self { value: 0 } }

    fn handle_key(&mut self, key: &Key) -> bool {
        match key {
            Key::Up => { self.value += 1; true }
            Key::Down => { self.value -= 1; true }
            _ => false,
        }
    }
}

impl View for Counter {
    fn render(&self, ctx: &mut RenderContext) {
        vstack()
            .child(Text::new(format!("Count: {}", self.value)))
            .child(Text::muted("[↑/↓] to change, [q] to quit"))
            .render(ctx);
    }
}

§CSS Styling

Revue supports CSS for styling widgets:

/* styles.css */
:root {
    --primary: #bd93f9;
    --bg: #282a36;
}

.button {
    background: var(--primary);
    color: var(--bg);
    transition: background 0.3s ease;
}

.button:hover {
    background: #ff79c6;
}

§Reactive State

use revue::prelude::*;

let count = signal(0);
let doubled = computed(move || count.get() * 2);

effect(move || {
    println!("Count changed to: {}", count.get());
});

count.set(5); // Triggers effect, doubled is now 10

§Layout

§Input

§Display

§Data

§Feedback

§Module Overview

ModuleDescription
appApplication lifecycle and event loop
domVirtual DOM and rendering tree
eventKeyboard/mouse events and keymaps
layoutFlexbox layout engine
reactiveSignal/Computed/Effect primitives
renderTerminal rendering and buffer
styleCSS parsing and theming
testingPilot testing framework
widgetAll widget implementations
workerBackground task execution

§Testing with Pilot

use revue::testing::{Pilot, TestApp};

#[test]
fn test_counter() {
    let mut app = TestApp::new(Counter::new());
    let mut pilot = Pilot::new(&mut app);

    pilot
        .press(Key::Up)
        .press(Key::Up)
        .assert_contains("2");
}

§Themes

Built-in themes available via style::themes:

  • Dracula - Dark purple theme
  • Nord - Arctic blue theme
  • Monokai - Classic dark theme
  • Gruvbox - Retro groove theme
  • Catppuccin - Pastel dark theme

§Comparison with Other Frameworks

FeatureRevueRatatuiTextualCursive
LanguageRustRustPythonRust
CSS Styling
Reactive State
Hot Reload
Widget Count80+1335+40+
Snapshot Testing

Modules§

a11y
Screen reader backend integration
app
Application lifecycle and coordination
constants
Common constants used throughout Revue
devtools
Developer tools for Revue applications
dom
DOM (Document Object Model) system for widget styling
event
Event handling and keyboard input
layout
Layout engine for TUI
patterns
Common patterns for TUI applications
plugin
Plugin system for extending Revue applications
prelude
Error Handling Guidelines
query
Query DSL for filtering and searching items
reactive
Reactive state management system.
render
Terminal rendering
style
CSS styling system for Revue.
tasks
Task management for async operations in TUI apps
testing
Pilot testing framework for automated UI tests.
text
Unicode and text handling
utils
Common utilities for widget rendering
widget
Widget system for Revue TUI framework.
worker
Worker system for background tasks

Macros§

a11y_assert
Convenience macro for accessibility assertions
assert_snapshot
Assert that a view matches its snapshot
bordered
Create a border with a child
hstack
Create a horizontal stack with children
impl_props_builders
Generate builder methods for widgets with props: WidgetProps field.
impl_queryable
Helper macro for implementing Queryable
impl_state_builders
Generate builder methods for widgets with state: WidgetState field.
impl_styled_view
Generate View trait implementation for StyledView widgets.
impl_view_meta
Generate View trait id(), classes(), and meta() methods for widgets with props.
impl_widget_builders
Generate all common builder methods for widgets with both state: WidgetState and props: WidgetProps fields.
text
Create text with common styling
translations
Macro for creating translations
ui
Build a complete UI layout declaratively
vstack
Create a vertical stack with children

Enums§

Error
Error type for Revue operations.

Constants§

GIT_SHA
The full git commit hash of this build.
VERSION
The version of the library, including the git commit hash in development builds.

Functions§

is_dev_build
Whether this is a development build (with commit hash in version) or a release build.

Type Aliases§

Result
Result type alias for Revue operations.

Derive Macros§

Store
Derive macro for the Store trait