opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

Build terminal UIs with a React-like component model in Rust
GitHub RepoImpressions4

Project Description

View on GitHub

Build Terminal UIs Like a Web Dev With iocraft

Rust has a ton of great terminal UI frameworks out there. But most of them ask you to think in terms of drawing widgets, handling events manually, and managing state yourself. If you've spent time building frontend apps with React or similar libraries, that might feel a bit backward.

That's where iocraft comes in. It brings a component model to terminal UIs in Rust that will feel instantly familiar if you've worked with React. You get props, hooks, children, virtual DOM diffing, and even async components. And the output is just a normal terminal UI.

What It Does

iocraft is a Rust library for building interactive terminal applications using a component tree. Instead of manually laying out text and handling redraws, you write components that return other components or custom elements. The library takes care of rendering, diffing, and updating the terminal only where things changed.

A simple example looks like this:

use iocraft::prelude::*;

#[derive(Default)]
struct App;

impl Component for App {
    fn render(&self, hooks: &mut Hooks) -> Result<Elements> {
        let mut count = hooks.use_state(|| 0);

        Ok(element! {
            Box(border: true, padding: 1) {
                Text(content: format!("Count: {}", count))
                Button(
                    on_press: move |_| count += 1,
                ) {
                    Text(content: "Increment")
                }
            }
        })
    }
}

This isn't just syntax sugar. It really is a virtual DOM with a diffing engine underneath.

Why It's Cool

A few things stand out about iocraft compared to other terminal UI libraries:

React-like hooks. You get use_state, use_effect, use_ref, and more. State changes cause targeted redraws of just the affected component, not the whole terminal.

Layout that works. The built-in layout engine uses a flexbox-like model (Box, Stack, Grid). You can align, pad, border, and position elements in ways that feel intuitive if you've done any web or mobile UI work.

Async components. This is unusual for terminal UI frameworks. You can write a component that fetches data or waits on an event without blocking the whole application. Think loading spinners that animate while a network request runs in the background.

No runtime panic abuse. The library is built around proper error handling with Result returns, not unwraps.

Performance. The virtual DOM diffing means you don't blink the whole screen on every keystroke like some older terminal libraries do.

How to Try It

Add iocraft to your project:

[dependencies]
iocraft = "0.2"

Then check the examples folder for demos you can run directly. There's a full counter app, form inputs, async spinners, and more.

If you want to see something working in a few minutes, the readme has a complete counter example you can copy, paste, run.

Final Thoughts

iocraft won't replace libraries like ratatui or cursive for every use case. Those tools are battle tested and do some things differently. But if you come from web development and want to build a CLI tool or terminal dashboard without learning a whole new paradigm around screen buffers and draw events, this is worth a look.

It's still early, but the design is clean and the idea is solid. For side projects, internal tools, or anything where development speed and code readability matter more than raw terminal hackery, iocraft is a genuinely pleasant way to build terminal UIs in Rust.


Found this interesting? Follow @githubprojects for more dev tools and open source projects.

Back to Projects
Project ID: bac83efe-63fe-4378-88c0-fea04b8b14a7Last updated: July 28, 2026 at 05:32 AM