mkui
A minimalist, typography-driven TUI library with Kitty graphics support.
Philosophy
- Good form: Typography-first visual hierarchy, avoiding heavy borders
- Hybrid rendering: Retained component structure + immediate mode rendering
- Performance: Built for audio/music applications with real-time requirements
- Graphics: Native support for Kitty, Sixel, and fallback to Unicode blocks
Architecture
mkui/
├── terminal.rs # Terminal geometry & capability detection
├── render.rs # Rendering backend with Kitty graphics
├── event.rs # Keyboard, mouse, and terminal events
├── layout.rs # Flex-based layout system
├── component.rs # Component trait & lifecycle
└── components/ # Built-in components
├── container.rs # Flex container
├── text.rs # Text with styling
├── header.rs # Top bar
└── status_bar.rs # Bottom bar
Running the Demo
Press q or ESC to quit.
Usage Example
use ;
Components
Container
Flex-based layout container supporting row/column direction, gaps, and padding.
Text
Styled text with alignment (left, center, right) and ANSI color codes.
Header
Top bar with centered title and inverse video styling.
StatusBar
Bottom bar with left, center, and right text sections.
Graphics Rendering
The renderer automatically detects and uses the best available graphics backend (in priority order):
- Linux framebuffer (
/dev/fb0) - Direct rendering in TTYs without X/Wayland - Kitty graphics - High-performance PNG rendering with chunking and tmux passthrough
- Sixel - Fallback for xterm, mlterm, iTerm2, and compatible terminals
- Unicode blocks - Universal fallback using
░▒▓█characters
Backend Selection
Auto-detection happens on Renderer::new():
let renderer = new?;
println!;
Force a specific backend:
let renderer = with_backend?;
Rendering Images
// Raw RGB image data
let image_data: = generate_rgb_image;
renderer.render_image?;
Graphics Demo
Test all backends with:
Press r to render a test gradient image.
TODO
- Optimize framebuffer rendering (currently basic implementation)
- Improve Sixel encoding (consider libsixel integration)
- Add more components (Button, List, ScrollView, etc.)
- Implement focus management system
- Add keyboard navigation
- Create waveform/spectrogram visualization components
- Build complete ponder UI on top of mkui