vtcode-design
Centralized design system for VT Code: unified color conversion, style bridging, design constants, layout, and base widget primitives.
vtcode-design is the single source of truth for all design system concerns in VT Code. It consolidates color mapping, style conversion, layout logic, and UI primitives that were previously scattered across vtcode-commons and vtcode-tui.
Highlights
- Correct Color Mapping — unified
anstyletoratatuicolor conversion that fixes prior bugs (Magenta mapped to DarkGray, bright variants mapped to non-bright, Ansi256 mapped to Reset). - Style Bridging — seamless conversion between
anstyle::Styleandratatui::style::Style, including effects/modifier mapping. - Responsive Layout —
LayoutModeenum (Compact/Standard/Wide) driven by terminal dimensions, controlling borders, titles, sidebar, and footer visibility. - Design Constants — shared UI tokens for ellipses, layout breakpoints, and spacing.
- Panel Primitive — base widget that renders standardized chrome (borders, titles) with decoupled styling via
PanelStyleProvidertrait. - Diff Formatting — unified diff rendering with ANSI colors, re-exporting core diff types from
vtcode-commons.
Modules
| Module | Purpose |
|---|---|
color |
Unified anstyle to ratatui color mapping (all 16 ANSI colors, 256-color palette, true color) |
style |
Style bridging: anstyle::Style and InlineTextStyle to ratatui::style::Style, effects conversion |
constants |
Shared UI constants: ellipsis characters, layout breakpoints, spacing tokens |
layout |
LayoutMode enum with responsive logic based on terminal dimensions |
panel |
Panel widget primitive with PanelStyleProvider and PanelStyles traits |
diff |
Unified diff formatting with ANSI colors, re-exports core diff types from vtcode-commons |
Public entrypoints
anstyle_to_ratatui_color— canonical color conversion functionanstyle_to_ratatui_style— full style conversionfg_style/bg_style/fg_bg_style/with_effects/colored_with_effects— convenience style buildersLayoutMode— responsive layout mode enumPanel/PanelStyleProvider/PanelStyles— panel widget and styling traitsformat_colored_diff/format_unified_diff/compute_diff_with_theme— diff formattingELLIPSIS/ELLIPSIS_CHAR/ELLIPSIS_ASCII— ellipsis constantsCOMPACT_MAX_COLS/WIDE_MIN_COLS/SPACING_TIGHT/SPACING_NORMAL/SPACING_LOOSE— layout and spacing constants
Usage
use anstyle_to_ratatui_color;
use ;
use LayoutMode;
use ;
use ;
use Rect;
// Convert colors
let ratatui_color = anstyle_to_ratatui_color;
// Build styles
let style = fg_style;
// Responsive layout
let mode = from_area;
assert!;
assert!;
// Design constants
let truncated = format!;
Bug fixes over prior implementations
This crate fixes several color mapping bugs from previous implementations in vtcode-commons::anstyle_utils and vtcode-tui::core_tui::style:
Magentaincorrectly mapped toDarkGray(now correctlyMagenta)BrightMagentaincorrectly mapped toDarkGray(now correctlyLightMagenta)BrightRed/Green/Yellow/Blue/Cyanmapped to non-bright variants (now correctlyLight*)Ansi256colors mapped toResetinstead ofIndexed(now correctlyIndexed)