modalx
A responsive, declarative, box-encapsulated Terminal User Interface (TUI) and modal dialog engine for Rust, built directly on crossterm.
╭──────────────────────────────────────────────────────────────────────────────╮
│ CLOUD INFRASTRUCTURE DASHBOARD │
├──────────────────────────────────────────────────────────────────────────────┤
│ Host: Ubuntu-Workstation | RAM: 14.2 / 32.0 GB (44.3%) | Status: [HEALTHY] │
│ Active Services: 18 | Alerts: 0 | Network: 1.2 Gbps │
├──────────────────────────────────────────────────────────────────────────────┤
│ > [1] Virtual Machines │
│ [2] Kubernetes Clusters │
│ [3] Persistent Volumes │
│ [4] Security Groups & Firewall │
│ [5] Audit & Access Logs │
│ [6] Billing & Usage │
├──────────────────────────────────────────────────────────────────────────────┤
│ [↑/↓/j/k] Move | [Enter/→] Select | [Esc/←] Back | [q] Exit │
╰──────────────────────────────────────────────────────────────────────────────╯
Core Capabilities
- Strict Unicode Box Encapsulation: All visual content is contained within Unicode borders (
╭─╮,│ │,├─┤,╰─╯) with automatic ASCII fallback. Boundaries never clip, overflow, or break terminal line layouts. - Responsive Terminal Protection: Detects constrained viewports (< 60 columns x 14 rows), pauses execution with a centered warning card, and automatically resumes on resize.
- Dynamic Greedy Reflow: Delimited metadata tokens (e.g.
Host: ... | RAM: ... | Status: ...) dynamically wrap across multiple framed lines rather than truncating with ellipses. - Full Modal Library:
SelectModal: Searchable, paginated keyboard-driven menus with hotkeys and vim navigation.FormModal: Multi-field forms with real-time validators, keystroke force-validators, masked password fields, integer/numeric constraints, and unsaved changes confirmation.InputModal: Readline text editing with word jump, character deletion, password masking, and custom validation.ConfirmModal: Affirmative/negative prompts with horizontal centering, default focus control, and danger mode styling.InfoModal: Multi-line scrollable dialogs with contextual shortcut bars that omit scroll hints when content fits the viewport.TableModal: Multi-column tabular data displays with column alignment (Left, Center, Right) and row selection.WaitingModal: In-place progress monitors with smooth animated braille spinners and multi-step checklists.
- Dynamic Shortcuts Engine: Contextual shortcut bar (
Shortcuts,ShortcutBar) with automatic deduction and formatted bracketed key hints. - RAII Terminal Safety: Process-wide panic hook ensuring raw mode is disabled and cursor visibility is restored on unexpected exits.
Installation
Add modalx to your Cargo.toml:
[]
= "0.1"
Or install via Cargo CLI:
Or run the quickstart script:
|
Quickstart
1. Menu Selection
use *;
2. Multi-Field Form with Validation
use *;
3. Destructive Confirmation Dialog
use *;
Examples
Run any of the included examples:
# Minimal menu selection
# Responsive dashboard with metadata reflow
# Multi-step wizard chaining inputs, menus, and confirms
# Structured data table viewer
# Multi-step animated progress spinner
Documentation
Comprehensive documentation, architecture guides, and cookbooks are available on the official documentation site.
License
MIT (c) Oguzhan Umutlu