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
//! Table widget demos
use crate::example::Example;
use crate::theme_colors;
use revue::prelude::*;
use revue::widget::{Column, DataGrid, GridColumn, GridRow, Pagination, Table};
pub fn examples() -> Vec<Example> {
let (_primary, _success, _warning, _error, _info, muted, _text, _) = theme_colors();
vec![
Example::new(
"Table",
"Basic table with column headers and row data",
Border::rounded().title(" Table ").child(
vstack()
.gap(1)
.child(
Table::new(vec![
Column::new("ID"),
Column::new("Name"),
Column::new("Status"),
Column::new("CPU"),
])
.row(vec!["001", "web-server", "●", "42%"])
.row(vec!["002", "api-gateway", "●", "67%"])
.row(vec!["003", "database", "●", "89%"])
.row(vec!["004", "cache", "○", "0%"])
.row(vec!["005", "worker", "●", "23%"]),
)
.child(Text::new(""))
.child(Text::new("• Column headers").fg(muted))
.child(Text::new("• Row data").fg(muted))
.child(Text::new("• Sortable columns").fg(muted)),
),
),
Example::new(
"Data Grid",
"Spreadsheet-like grid with editable cells",
Border::rounded().title(" Data Grid ").child(
vstack()
.gap(1)
.child(
DataGrid::new()
.column(GridColumn::new("Product", "Product"))
.column(GridColumn::new("Q1", "Q1"))
.column(GridColumn::new("Q2", "Q2"))
.column(GridColumn::new("Q3", "Q3"))
.column(GridColumn::new("Q4", "Q4"))
.header(true)
.row(
GridRow::new()
.cell("Product", "Widget A")
.cell("Q1", "120")
.cell("Q2", "145")
.cell("Q3", "138")
.cell("Q4", "160"),
)
.row(
GridRow::new()
.cell("Product", "Widget B")
.cell("Q1", "85")
.cell("Q2", "92")
.cell("Q3", "105")
.cell("Q4", "98"),
)
.row(
GridRow::new()
.cell("Product", "Widget C")
.cell("Q1", "200")
.cell("Q2", "180")
.cell("Q3", "220")
.cell("Q4", "250"),
)
.row(
GridRow::new()
.cell("Product", "Widget D")
.cell("Q1", "45")
.cell("Q2", "52")
.cell("Q3", "48")
.cell("Q4", "55"),
),
)
.child(Text::new(""))
.child(Text::new("• Editable cells").fg(muted))
.child(Text::new("• Row selection").fg(muted))
.child(Text::new("• Spreadsheet-like").fg(muted)),
),
),
Example::new(
"Styled Table",
"Table with conditional styling and status indicators",
Border::rounded().title(" Styled Table ").child(
vstack()
.gap(1)
.child(
Table::new(vec![
Column::new("Service").width(12),
Column::new("Status").width(8),
Column::new("Health").width(8),
])
.row(vec!["API", "Running", "98%"])
.row(vec!["Database", "Running", "76%"])
.row(vec!["Cache", "Stopped", "0%"]),
)
.child(Text::new(""))
.child(Text::new("• Colored cells").fg(muted))
.child(Text::new("• Conditional styling").fg(muted))
.child(Text::new("• Status indicators").fg(muted)),
),
),
Example::new(
"Paginated",
"Table with pagination for large datasets",
Border::rounded().title(" Paginated ").child(
vstack()
.gap(1)
.child(
Table::new(vec![
Column::new("#"),
Column::new("Item"),
Column::new("Value"),
])
.row(vec!["1", "Alpha", "$120"])
.row(vec!["2", "Beta", "$85"])
.row(vec!["3", "Gamma", "$200"])
.row(vec!["4", "Delta", "$45"])
.row(vec!["5", "Epsilon", "$95"]),
)
.child(Pagination::new(10).current(1))
.child(Text::new(""))
.child(Text::new("• Large datasets").fg(muted))
.child(Text::new("• Navigation controls").fg(muted))
.child(Text::new("• Page size options").fg(muted)),
),
),
Example::new(
"Sortable Table",
"Table with clickable column headers for sorting",
Border::rounded().title(" Sortable Table ").child(
vstack()
.gap(1)
.child(
Table::new(vec![
Column::new("Name"),
Column::new("Date"),
Column::new("Size"),
])
.row(vec!["config.toml", "2026-01-15", "2.1 KB"])
.row(vec!["main.rs", "2026-02-20", "15.3 KB"])
.row(vec!["data.json", "2026-02-28", "8.7 KB"]),
)
.child(Text::new(""))
.child(Text::new("• Click headers to sort").fg(muted))
.child(Text::new("• Ascending/descending").fg(muted))
.child(Text::new("• Sort indicator").fg(muted)),
),
),
Example::new(
"Selection",
"Table with row selection and checkboxes",
Border::rounded().title(" Selection ").child(
vstack()
.gap(1)
.child(
Table::new(vec![
Column::new(""),
Column::new("Task"),
Column::new("Due"),
])
.row(vec!["☐", "Write docs", "2026-03-01"])
.row(vec!["☑", "Fix bugs", "2026-03-02"])
.row(vec!["☐", "Review PR", "2026-03-03"])
.row(vec!["☑", "Deploy", "2026-03-05"]),
)
.child(Text::new(""))
.child(Text::new("• Row selection").fg(muted))
.child(Text::new("• Multi-select option").fg(muted))
.child(Text::new("• Checkbox column").fg(muted)),
),
),
]
}