MCPcopy Index your code
hub / github.com/enricozb/intuitive

github.com/enricozb/intuitive @v0.6.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.1 ↗ · + Follow
178 symbols 327 edges 40 files 24 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Intuitive

docs.rs Documentation

Intuitive is a component-based library for creating text-based user interfaces (TUIs) easily.

It is heavily inspired by React and SwiftUI, containing features that resemble functional components, hooks, and a (mostly) declarative DSL.

Refer to the Getting Started documentation for a detailed guide on how to get started with Intuitive. Alternatively, head over to the examples directory to see some demo applications.

Design

The main focus of Intuitive is to simplify the implementation of section-based TUIs, such as lazygit's, even at the slight expense of performance. Intuitive attempts to make it easy to write reusable TUI components that - encapsulate logic around handling state and key events - have complex layouts - are easy to read

For example, a complex layout with an input box:

use intuitive::{
  component,
  components::{stack::Flex::*, HStack, Section, Text, VStack},
  error::Result,
  on_key, render,
  state::use_state,
  terminal::Terminal,
};

#[component(Root)]
fn render() {
  let text = use_state(|| String::new());

  let on_key = on_key! { [text]
    KeyEvent { code: Char(c), .. } => text.mutate(|text| text.push(c)),
    KeyEvent { code: Backspace, .. } => text.mutate(|text| text.pop()),
    KeyEvent { code: Esc, .. } => event::quit(),
  };

  render! {
    VStack(flex: [Block(3), Grow(1)], on_key) {
      Section(title: "Input") {
        Text(text: text.get())
      }

      HStack(flex: [1, 2, 3]) {
        Section(title: "Column 1")
        Section(title: "Column 2")
        Section(title: "Column 3")
      }
    }
  }
}

fn main() -> Result<()> {
  Terminal::new(Root::new())?.run()
}

And the output would look like this:

demo

Disclaimer

Intuitive is closer to a proof-of-concept than to a crate that's ready for prime-time use. There may also be some bugs in the library of components, please raise an issue if you find any. Furthermore, since a large and complex application has yet to be built using Intuitive, it is not a guarantee that it does not have some major flaw making such development difficult.

Extension points exported contracts — how you extend this code

Element (Interface)
A rendered component. Once a [`Component`] is rendered, it now can be drawn (through [`draw`]) or it can handle a key e [9 …
intuitive/src/element.rs
Component (Interface)
A trait describing structures that can be rendered to an [`Element`]. Before implementing the `Component` trait directl [3 …
intuitive/src/components/mod.rs

Core symbols most depended-on inside this repo

clone
called by 29
intuitive/src/state/mod.rs
use_state
called by 19
intuitive/src/state/hook.rs
render_done
called by 9
intuitive/src/state/hook.rs
setup
called by 7
intuitive/src/state/hook.rs
handle_or
called by 7
intuitive/src/event/handler.rs
render
called by 6
intuitive/src/components/children.rs
get
called by 6
intuitive/src/state/mod.rs
re_render
called by 6
intuitive/src/event/channel.rs

Shape

Method 101
Function 36
Class 32
Enum 7
Interface 2

Languages

Rust100%

Modules by API surface

intuitive/src/state/hook.rs9 symbols
intuitive/src/event/channel.rs9 symbols
intuitive/src/element.rs9 symbols
intuitive/src/components/experimental_components/scroll/mod.rs9 symbols
intuitive/src/state/mod.rs8 symbols
intuitive/src/event/handler.rs8 symbols
intuitive/src/text.rs7 symbols
intuitive/src/terminal.rs7 symbols
intuitive/src/state/state.rs7 symbols
intuitive/src/components/experimental_components/table/widget.rs7 symbols
intuitive/src/components/experimental_components/modal/hook.rs7 symbols
intuitive/src/components/stack/vertical.rs6 symbols

For agents

$ claude mcp add intuitive \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact