revue 2.71.1

A Vue-style TUI framework for Rust with CSS styling
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
//! Widget system for Revue TUI framework.
//!
//! This module provides 92+ widgets for building terminal user interfaces.
//! Widgets are organized into categories for easy discovery.
//!
//! # Widget Categories
//!
//! ## Layout Widgets
//!
//! | Widget | Description | Constructor |
//! |--------|-------------|-------------|
//! | [`Stack`] | Vertical/horizontal layout | [`vstack()`], [`hstack()`] |
//! | [`Border`] | Bordered container | [`border()`] |
//! | [`Tabs`] | Tab navigation | [`tabs()`] |
//! | [`ScrollView`] | Scrollable area | [`scroll_view()`] |
//! | [`Layers`] | Overlapping widgets | [`layers()`] |
//! | [`Positioned`] | Absolute positioning | [`positioned()`] |
//! | [`Grid`] | CSS Grid layout | [`grid()`] |
//! | [`Splitter`] | Resizable panes | [`hsplit()`], [`vsplit()`] |
//! | [`Accordion`] | Collapsible sections | [`accordion()`] |
//! | [`Collapsible`] | Single expandable section | [`collapsible()`] |
//! | [`Card`] | Content container | [`card()`] |
//! | [`Screen`] | Screen navigation | [`screen()`] |
//! | [`Sidebar`] | Vertical nav rail | [`sidebar()`] |
//!
//! ## Input Widgets
//!
//! | Widget | Description | Constructor |
//! |--------|-------------|-------------|
//! | [`Input`] | Single-line text input | [`input()`] |
//! | [`TextArea`] | Multi-line editor | [`textarea()`] |
//! | [`Button`] | Clickable button | [`button()`] |
//! | [`Checkbox`] | Toggle checkbox | [`checkbox()`] |
//! | [`RadioGroup`] | Radio selection | [`radio_group()`] |
//! | [`Select`] | Dropdown menu | [`select()`] |
//! | [`Combobox`] | Autocomplete dropdown | [`combobox()`] |
//! | [`Switch`] | Toggle switch | [`switch()`] |
//! | [`Slider`] | Value slider | [`slider()`] |
//! | [`ColorPicker`] | Color selection | [`color_picker()`] |
//! | [`CommandPalette`] | Fuzzy command search | [`command_palette()`] |
//!
//! ## Display Widgets
//!
//! | Widget | Description | Constructor |
//! |--------|-------------|-------------|
//! | [`Text`] | Styled text | [`text()`] |
//! | [`RichText`] | Markup text | [`rich_text()`] |
//! | [`Progress`] | Progress bar | [`progress()`] |
//! | [`Spinner`] | Loading indicator | [`spinner()`] |
//! | [`Gauge`] | Circular gauge | [`gauge()`] |
//! | [`Badge`] | Status badge | [`badge()`] |
//! | [`Tag`] | Label tag | [`tag()`] |
//! | [`Avatar`] | User avatar | [`avatar()`] |
//! | [`GradientBox`] | Gradient background | [`gradient_box()`] |
//! | [`Skeleton`] | Loading placeholder | [`skeleton()`] |
//! | [`Divider`] | Visual separator | [`divider()`] |
//! | [`Tooltip`] | Hover tooltip | [`tooltip()`] |
//! | [`Breadcrumb`] | Navigation trail | [`breadcrumb()`] |
//! | [`Stepper`] | Step indicator | [`stepper()`] |
//! | [`Alert`] | Persistent feedback | [`alert()`] |
//! | [`Callout`] | Info highlight block | [`callout()`], [`note()`], [`tip()`] |
//! | [`EmptyState`] | No-data placeholder | [`empty_state()`] |
//! | [`StatusIndicator`] | Availability status | [`status_indicator()`], [`online()`] |
//!
//! ## Data Widgets
//!
//! | Widget | Description | Constructor |
//! |--------|-------------|-------------|
//! | [`Table`] | Data table | [`table()`] |
//! | [`DataGrid`] | Advanced grid | [`datagrid()`] |
//! | [`List`] | Selectable list | [`list()`] |
//! | [`Tree`] | Hierarchical tree | [`tree()`] |
//! | [`FileTree`] | File browser | [`file_tree()`] |
//! | [`Calendar`] | Date picker | [`calendar()`] |
//! | [`DateTimePicker`] | Date/time picker | [`datetime_picker()`] |
//! | [`Timeline`] | Event timeline | [`timeline()`] |
//! | [`RichLog`] | Log viewer | [`richlog()`] |
//! | [`LogViewer`] | Advanced log viewer | [`log_viewer()`] |
//! | [`CsvViewer`] | CSV/TSV data viewer | [`csv_viewer()`] |
//! | [`JsonViewer`] | JSON tree viewer | [`json_viewer()`] |
//!
//! ## Chart Widgets
//!
//! | Widget | Description | Constructor |
//! |--------|-------------|-------------|
//! | [`Sparkline`] | Mini line chart | [`sparkline()`] |
//! | [`BarChart`] | Bar chart | [`barchart()`] |
//! | [`Chart`] | Full charts | [`chart()`], [`line_chart()`] |
//! | [`Canvas`] | Custom drawing | [`canvas()`] |
//! | [`BrailleCanvas`] | High-res drawing | [`braille_canvas()`] |
//!
//! ## Feedback Widgets
//!
//! | Widget | Description | Constructor |
//! |--------|-------------|-------------|
//! | [`Modal`] | Dialog overlay | [`modal()`] |
//! | [`Toast`] | Notification popup | [`toast()`] |
//! | [`NotificationCenter`] | Notification manager | [`notification_center()`] |
//! | [`Menu`] | Dropdown menu | [`menu()`] |
//! | [`ContextMenu`] | Right-click menu | [`context_menu()`] |
//! | [`Popover`] | Anchor-positioned overlay | [`popover()`] |
//! | [`StatusBar`] | App status bar | [`statusbar()`] |
//!
//! ## Developer Widgets
//!
//! | Widget | Description | Constructor |
//! |--------|-------------|-------------|
//! | [`AiStream`] | AI streaming text | [`ai_stream()`] |
//! | [`Presentation`] | Terminal slideshows | [`presentation()`] |
//! | [`Diagram`] | Mermaid diagrams | [`diagram()`] |
//! | [`VimState`] | Vim mode support | [`vim_state()`] |
//! | [`HttpClient`] | REST API client | [`http_client()`] |
//!
//! # Quick Start
//!
//! ```rust,ignore
//! use revue::prelude::*;
//!
//! // Simple layout
//! let ui = vstack()
//!     .gap(1)
//!     .child(Text::new("Hello, Revue!").bold())
//!     .child(button("Click me").on_click(|| println!("Clicked!")));
//!
//! // With borders
//! let panel = Border::rounded()
//!     .title("My Panel")
//!     .child(ui);
//! ```
//!
//! # Constructor Pattern
//!
//! Revue uses a **hybrid constructor pattern** to balance ergonomics and clarity:
//!
//! ## Function-Style (Simple Widgets)
//!
//! Widgets with fewer than 5 configuration options use function-style constructors:
//!
//! ```rust,ignore
//! use revue::prelude::*;
//!
//! // Simple, single-purpose widgets
//! let btn = button("Click me");
//! let chk = checkbox("Enable");
//! let txt = text("Hello");
//! let badge = badge("New");
//! let divider = divider();
//! ```
//!
//! **Benefits**: Concise, chainable, IDE-friendly autocomplete.
//!
//! ## Builder-Style (Complex Widgets)
//!
//! Widgets with 5+ configuration options use builder-style:
//!
//! ```rust,ignore
//! use revue::prelude::*;
//!
//! // Complex widgets with many options
//! let grid = DataGrid::builder()
//!     .columns(vec![/* ... */])
//!     .data(&data)
//!     .selectable(true)
//!     .sortable(true)
//!     .build();
//! ```
//!
//! **Benefits**: Clear option names, handles complex configuration well.
//!
//! ## Creating New Widgets
//!
//! When adding new widgets, follow this guideline:
//!
//! | Config Options | Pattern | Example |
//! |----------------|---------|---------|
//! | < 5 | Function-style | `button()`, `text()` |
//! | >= 5 | Builder-style | `DataGrid::builder()` |
//!
//! ## Transition Period
//!
//! Some widgets may have both patterns during migration. Prefer function-style
//! for simple widgets, but `Widget::new()` remains valid for all widgets.
//!
//! # Creating Custom Widgets
//!
//! Implement the [`View`] trait to create custom widgets:
//!
//! ```rust,ignore
//! use revue::prelude::*;
//!
//! struct MyWidget {
//!     label: String,
//! }
//!
//! impl View for MyWidget {
//!     fn render(&self, ctx: &mut RenderContext) {
//!         Text::new(&self.label)
//!             .fg(Color::CYAN)
//!             .render(ctx);
//!     }
//! }
//! ```
//!
//! # Styling
//!
//! Most widgets support styling via builder methods:
//!
//! ```rust,ignore
//! Text::new("Styled")
//!     .fg(Color::CYAN)
//!     .bg(Color::rgb(30, 30, 46))
//!     .bold()
//!     .italic();
//!
//! Progress::new(0.75)
//!     .filled_color(Color::GREEN)
//!     .show_percentage(true);
//!
//! Border::rounded()
//!     .title("Panel")
//!     .fg(Color::BLUE);
//! ```

mod breadcrumb;
// Note: calendar moved to data/calendar
mod callout;
mod canvas;
mod command_palette;
pub mod data; // Data widgets (calendar, chart, table, timer, etc.)
mod datetime_picker;
mod debug_overlay;
mod developer;
mod display;
mod dropzone;
mod feedback;
mod filepicker;
mod form;
#[cfg(feature = "image")]
mod image;
// Input widgets (moved to input/input_widgets/)
#[path = "input/input_widgets/mod.rs"]
pub mod input_widgets;
mod layout;
mod link;
#[cfg(feature = "markdown")]
pub mod markdown;
#[cfg(feature = "markdown")]
mod markdown_presentation;
mod mermaid;
mod multi_select;
mod option_list;
mod pagination;
#[cfg(feature = "qrcode")]
mod qrcode;
mod range_picker;
#[cfg(feature = "markdown")]
pub mod slides;
mod sortable;
mod streamline;
pub mod syntax; // Syntax highlighting module
pub mod theme;
mod theme_picker;
// Note: timer moved to data/timer
pub mod traits;
mod transition;
pub mod validation;
mod zen;
#[macro_use]
mod macros;

pub use crate::utils::border::BorderChars;
// Display widgets (re-exported from display module)
pub use display::{
    avatar, avatar_icon, away_indicator, badge, battery, bigtext, busy_indicator, chip, clock,
    digits, divider, dot_badge, empty_error, empty_state, first_use, gauge, gradient_box, h1, h2,
    h3, log_entry, markup, no_results, offline, online, percentage, progress, rich_text, richlog,
    skeleton, skeleton_avatar, skeleton_paragraph, skeleton_text, span, spinner, status_indicator,
    style, tag, text, vdivider, Alignment, Avatar, AvatarShape, AvatarSize, Badge, BadgeShape,
    BadgeVariant, BigText, DigitStyle, Digits, Divider, DividerStyle, EmptyState, EmptyStateType,
    EmptyStateVariant, Gauge, GaugeStyle, GradientBox, LabelPosition, LogEntry, LogFormat,
    LogLevel, Orientation, Progress, ProgressStyle, RichLog, RichText, Skeleton, SkeletonShape,
    Span, Spinner, SpinnerStyle, Status, StatusIndicator, StatusSize, StatusStyle, Style, Tag,
    TagStyle, Text,
};
// Layout widgets (re-exported from layout module)
pub use layout::{
    accordion, border, card, collapsible, draw_border, grid, grid_item, grid_template, hsplit,
    hstack, layer, layers, pane, positioned, resizable, screen, screen_stack, scroll, scroll_view,
    section, sidebar, sidebar_item, sidebar_section, sidebar_section_titled, splitter, stack, tabs,
    vsplit, vstack, Accordion, AccordionSection, Anchor, Border, BorderType, Card, CardVariant,
    CollapseMode, Collapsible, Direction, FlattenedItem, Grid, GridAlign, GridItem, GridPlacement,
    HSplit, Layers, Pane, Positioned, Resizable, ResizeDirection, ResizeHandle, ResizeStyle,
    Screen, ScreenStack, ScreenTransition, ScrollView, Sidebar, SidebarItem, SidebarSection,
    SplitOrientation, Splitter, Stack, Tab, Tabs, TrackSize, VSplit,
};
// Input widgets (re-exported from input_widgets module)
pub use breadcrumb::{breadcrumb, crumb, Breadcrumb, BreadcrumbItem, SeparatorStyle};
pub use callout::{
    callout, danger, important, info_callout, note, tip, warning_callout, Callout, CalloutType,
    CalloutVariant,
};
pub use canvas::{
    braille_canvas, canvas, Arc, BrailleCanvas, BrailleContext, BrailleGrid, Canvas, Circle,
    ClipRegion, DrawContext, FilledCircle, FilledPolygon, FilledRectangle, Layer, Line, Points,
    Polygon, Rectangle, Shape, Transform,
};
pub use command_palette::{command_palette, Command, CommandPalette};
pub use data::calendar::{
    calendar, days_in_month, Calendar, CalendarMode, Date, DateMarker, FirstDayOfWeek,
};
pub use datetime_picker::{
    date_picker, datetime_picker, time_picker, DateTime, DateTimeFormat, DateTimeMode,
    DateTimePicker, Time, TimeField,
};
pub use debug_overlay::{
    disable_debug, enable_debug, is_debug_enabled, toggle_debug, DebugConfig, DebugEvent,
    DebugOverlay, DebugPosition, EventLog, PerfMetrics, WidgetInfo,
};
pub use dropzone::{drop_zone, DropZone, DropZoneStyle};
pub use filepicker::{
    dir_picker, file_picker, save_picker, FileFilter, FilePicker, PickerEntry, PickerMode,
    PickerResult,
};
pub use input_widgets::{
    autocomplete, button, checkbox, color_picker, combobox, currency_input, input, integer_input,
    number_input, percentage_input, percentage_slider, radio_group, rating, search_bar, select,
    selection_item, selection_list, slider, slider_range, step, stepper, switch, textarea, toggle,
    volume_slider, Autocomplete, Button, ButtonVariant, Checkbox, CheckboxStyle, ColorPalette,
    ColorPicker, ColorPickerMode, ComboOption, Combobox, Input, NumberInput, RadioGroup,
    RadioLayout, RadioStyle, Rating, RatingSize, RatingStyle, SearchBar, Select, SelectionItem,
    SelectionList, SelectionStyle, Slider, SliderOrientation, SliderStyle, Step, StepStatus,
    Stepper, StepperOrientation, StepperStyle, Suggestion, Switch, SwitchStyle, TextArea,
};
// Form widgets (re-exported from form module)
#[cfg(feature = "qrcode")]
pub use self::qrcode::{qrcode, qrcode_url, ErrorCorrection, QrCodeWidget, QrStyle};
pub use data::timer::{pomodoro, timer as timer_widget, Timer, TimerFormat, TimerState};
pub use data::timer::{stopwatch, Stopwatch};
pub use form::{
    credit_card_input, form as form_widget, form_field, masked_input, password_input, pin_input,
    rich_text_editor, Block, BlockType, EditorViewMode, ErrorDisplayStyle, Form, FormField,
    FormFieldWidget, FormattedSpan, ImageRef, InputType, MarkdownLink, MaskStyle, MaskedInput,
    RichTextEditor, TextFormat, ToolbarAction, ValidationState,
};
#[cfg(feature = "image")]
pub use image::{image_from_file, try_image_from_file, Image, ImageError, ImageResult, ScaleMode};
pub use link::{link, url_link, Link, LinkStyle};
#[cfg(feature = "markdown")]
pub use markdown::{markdown, Markdown};
#[cfg(feature = "markdown")]
pub use markdown_presentation::{markdown_presentation, MarkdownPresentation, ViewMode};
pub use mermaid::{
    diagram, edge, flowchart, node, ArrowStyle, Diagram, DiagramEdge, DiagramNode, DiagramType,
    NodeShape,
};
pub use multi_select::{multi_select, multi_select_from, MultiSelect, MultiSelectOption};
pub use option_list::{
    option_item, option_list, OptionEntry, OptionItem, OptionList,
    SeparatorStyle as OptionSeparatorStyle,
};
pub use pagination::{pagination, Pagination, PaginationStyle};
pub use range_picker::{
    analytics_range_picker, date_range_picker, range_picker, PresetRange, RangeFocus, RangePicker,
};
#[cfg(feature = "markdown")]
pub use slides::{parse_slides, SlideContent, SlideNav};
pub use sortable::{sortable_list, SortableItem, SortableList};
pub use streamline::{
    genre_stream, resource_stream, streamline, streamline_with_data, traffic_stream,
    StreamBaseline, StreamLayer, StreamOrder, Streamline,
};
pub use syntax::{HighlightSpan, Language, SyntaxHighlighter, SyntaxTheme};
pub use theme::{
    DARK_BG, DARK_GRAY, EDITOR_BG, FOCUS_COLOR, LIGHT_GRAY, MAX_DROPDOWN_VISIBLE, MUTED_TEXT,
    PLACEHOLDER_FG, SECONDARY_TEXT, SEPARATOR_COLOR, SUBTLE_GRAY,
};
pub use theme_picker::{theme_picker, ThemePicker};
pub use traits::{
    Draggable, Element, EventResult, FocusStyle, Interactive, OverlayEntry, OverlayQueue,
    RenderContext, StyledView, Timeout, View, WidgetProps, WidgetState, DISABLED_BG, DISABLED_FG,
};
pub use transition::{
    transition, transition_group, Animation, AnimationPreset, Transition as AnimationTransition,
    TransitionGroup, TransitionPhase,
};
pub use validation::{validators, Validatable, ValidationError, ValidationResult};
pub use zen::{zen, zen_dark, zen_light, ZenMode};

// Chart widgets (re-exported from chart module)
pub use data::chart::{
    area_wave, audio_waveform, barchart, boxplot, bubble_chart, candle_chart, chart,
    contribution_map, cpu_chart, donut_chart, heatmap, histogram, line_chart, memory_chart,
    network_chart, ohlc_chart, pie_chart, piechart, sawtooth_wave, scatter_chart, scatter_plot,
    scatterchart, signal_wave, sine_wave, sparkline, spectrum, square_wave, time_series,
    time_series_with_data, waveline, BarChart, BarOrientation, BinConfig, BoxGroup, BoxPlot,
    BoxStats, Candle, CandleChart, CandleStyle, CellDisplay, Chart, ChartType, ColorScale, HeatMap,
    Histogram, HistogramBin, Interpolation, LineStyle, MarkerStyle, PieChart, PieLabelStyle,
    PieSlice, PieStyle, ScatterChart, ScatterSeries, Series, Sparkline, SparklineStyle, TimeFormat,
    TimeLineStyle, TimeMarker, TimePoint, TimeRange, TimeSeries, TimeSeriesData, WaveStyle,
    Waveline, WhiskerStyle,
};

// Data widgets (re-exported from data module)
pub use data::{
    adv_log_entry, column, csv_viewer, datagrid, dir_entry, file_entry, file_tree, grid_column,
    grid_row, json_viewer, list, log_filter, log_parser, log_viewer, table, timeline,
    timeline_event, tree, tree_node, virtual_list, AdvLogEntry, AdvLogLevel, Column, CsvSortOrder,
    CsvViewer, DataGrid, Delimiter, EventType, FileEntry, FileTree, FileType, GridColumn, GridRow,
    JsonNode, JsonType, JsonViewer, List, LogFilter, LogParser, LogViewer, ScrollAlignment,
    ScrollMode, Search, SearchMatch, SortDirection, Table, Timeline, TimelineEvent,
    TimelineOrientation, TimelineStyle, TimestampFormat, Tree, TreeNode, VirtualList,
};

// Feedback widgets (re-exported from feedback module)
pub use feedback::{
    alert, context_menu, error_alert, error_boundary, footer, header, info_alert, key_hint, menu,
    menu_bar, menu_item, modal, notification_center, popover, status_section, statusbar,
    success_alert, toast, toast_queue, tooltip, warning_alert, Alert, AlertLevel, AlertVariant,
    ContextMenu, ErrorBoundary, KeyHint, Menu, MenuBar, MenuItem, Modal, ModalButton,
    ModalButtonStyle, Notification, NotificationCenter, NotificationLevel, NotificationPosition,
    Popover, PopoverArrow, PopoverPosition, PopoverStyle, PopoverTrigger, SectionAlign,
    StackDirection, StatusBar, StatusSection, Toast, ToastEntry, ToastLevel, ToastPosition,
    ToastPriority, ToastQueue, Tooltip, TooltipArrow, TooltipPosition, TooltipStyle,
};

// Developer widgets (re-exported from developer module)
#[cfg(feature = "syntax-highlighting")]
pub use developer::TreeSitterHighlighter;
pub use developer::{
    ai_response, ai_stream, code_editor, http_client, http_delete, http_get, http_patch, http_post,
    http_put, presentation, slide, terminal, vim_state, AiStream, BracketMatch, BracketPair,
    CodeEditor, ContentType, CursorStyle, EditorConfig, HttpBackend, HttpClient, HttpMethod,
    HttpRequest, HttpResponse, IndentStyle, MockHttpBackend, Presentation, RequestBuilder,
    RequestState, ResponseView, Slide, SlideAlign, StreamCursor, StreamStatus, TermCell, TermLine,
    Terminal, TerminalAction, Transition, TypingStyle, VimAction, VimCommandResult, VimMode,
    VimMotion, VimState,
};
#[cfg(feature = "diff")]
pub use developer::{diff, diff_viewer, ChangeType, DiffColors, DiffLine, DiffMode, DiffViewer};
#[cfg(feature = "sysinfo")]
pub use developer::{
    htop, process_monitor, ProcColors, ProcessInfo, ProcessMonitor, ProcessSort, ProcessView,
};

// Re-export common widget constructors

/// Create a new text widget
pub fn text(content: impl Into<String>) -> Text {
    Text::new(content)
}