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
//! Tree widget demos
use crate::example::Example;
use crate::theme_colors;
use revue::prelude::*;
use revue::widget::{FileTree, Tree, TreeNode};
pub fn examples() -> Vec<Example> {
let (_primary, _success, _warning, _error, _info, muted, _text, _) = theme_colors();
vec![
Example::new(
"Tree",
"Hierarchical tree with expandable nodes",
Border::rounded().title(" Tree ").child(
vstack()
.gap(1)
.child(
Tree::new()
.node(
TreeNode::new("src")
.expanded(true)
.child(TreeNode::new("widget"))
.child(TreeNode::new("style"))
.child(TreeNode::new("lib.rs")),
)
.node(TreeNode::new("Cargo.toml"))
.node(TreeNode::new("README.md")),
)
.child(Text::new(""))
.child(Text::new("• Expandable nodes").fg(muted))
.child(Text::new("• Hierarchical data").fg(muted))
.child(Text::new("• Collapse/expand").fg(muted)),
),
),
Example::new(
"File Tree",
"File explorer with file and folder icons",
Border::rounded().title(" File Tree ").child(
vstack()
.gap(1)
.child(FileTree::new())
.child(Text::new(""))
.child(Text::new("• File/folder icons").fg(muted))
.child(Text::new("• Directory nesting").fg(muted))
.child(Text::new("• File explorer view").fg(muted)),
),
),
Example::new(
"Org Chart",
"Organizational hierarchy with reporting structure",
Border::rounded().title(" Org Chart ").child(
vstack()
.gap(1)
.child(
Tree::new().node(
TreeNode::new("CEO")
.expanded(true)
.child(
TreeNode::new("CTO")
.child(TreeNode::new("Engineering"))
.child(TreeNode::new("DevOps")),
)
.child(
TreeNode::new("CFO")
.child(TreeNode::new("Finance"))
.child(TreeNode::new("Accounting")),
),
),
)
.child(Text::new(""))
.child(Text::new("• Organizational view").fg(muted))
.child(Text::new("• Reporting structure").fg(muted))
.child(Text::new("• Employee hierarchy").fg(muted)),
),
),
Example::new(
"JSON Tree",
"Tree visualization of JSON data structure",
Border::rounded().title(" JSON Tree ").child(
vstack()
.gap(1)
.child(
Tree::new().node(
TreeNode::new("{ } root")
.expanded(true)
.child(TreeNode::new("\"name\": \"revue\""))
.child(TreeNode::new("\"version\": \"2.52.0\""))
.child(
TreeNode::new("\"dependencies\": { }")
.child(TreeNode::new("\"ratatui\": \"0.29\""))
.child(TreeNode::new("\"tokio\": \"1.0\"")),
)
.child(TreeNode::new("\"features\": [\"full\", \"async\"]")),
),
)
.child(Text::new(""))
.child(Text::new("• JSON visualization").fg(muted))
.child(Text::new("• Expand objects").fg(muted))
.child(Text::new("• Key/value pairs").fg(muted)),
),
),
Example::new(
"Checklist Tree",
"Nested task tree with checkbox progress states",
Border::rounded().title(" Checklist Tree ").child(
vstack()
.gap(1)
.child(
Tree::new()
.node(
TreeNode::new("☑ Phase 1: Setup")
.child(TreeNode::new("☑ Initialize project"))
.child(TreeNode::new("☑ Configure CI")),
)
.node(
TreeNode::new("◐ Phase 2: Development")
.expanded(true)
.child(TreeNode::new("☑ Core features"))
.child(TreeNode::new("☐ Testing"))
.child(TreeNode::new("☐ Documentation")),
)
.node(
TreeNode::new("☐ Phase 3: Release")
.child(TreeNode::new("☐ Review"))
.child(TreeNode::new("☐ Deploy")),
),
)
.child(Text::new(""))
.child(Text::new("• Progress tracking").fg(muted))
.child(Text::new("• Nested tasks").fg(muted))
.child(Text::new("• Checkbox states").fg(muted)),
),
),
Example::new(
"Category Tree",
"Category browser with emoji icons and navigation",
Border::rounded().title(" Category Tree ").child(
vstack()
.gap(1)
.child(
Tree::new()
.node(
TreeNode::new("📁 Documents")
.expanded(true)
.child(TreeNode::new("📄 Reports"))
.child(TreeNode::new("📄 Spreadsheets")),
)
.node(
TreeNode::new("📁 Images")
.child(TreeNode::new("🖼 Photos"))
.child(TreeNode::new("🎨 Graphics")),
)
.node(
TreeNode::new("📁 Code")
.child(TreeNode::new("⚙ Rust"))
.child(TreeNode::new("⚙ TypeScript")),
),
)
.child(Text::new(""))
.child(Text::new("• Category browser").fg(muted))
.child(Text::new("• Emoji icons").fg(muted))
.child(Text::new("• Navigation tree").fg(muted)),
),
),
]
}