x
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
<div class="flow-root" ><div class="overflow-x-auto max-h-[28rem]"> <div class="inline-block min-w-full align-middle"> <table class="table-auto min-w-full divide-y divide-gray-300"> <thead class="sticky top-0 bg-white"> <tr> <th class="px-3 py-4 text-left text-sm font-semibold text-gray-900 scope="col" > # </th> <th class="px-3 py-4 text-left text-sm font-semibold text-gray-900 scope="col" > Name </th> <th class="px-3 py-4 text-left text-sm font-semibold text-gray-900 scope="col" > Email </th> </tr> <tbody class="divide-y divide-gray-200"> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 1 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 1 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user1@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 2 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 2 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user2@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 3 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 3 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user3@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 4 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 4 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user4@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 5 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 5 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user5@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 6 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 6 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user6@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 7 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 7 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user7@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 8 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 8 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user8@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 9 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 9 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user9@example.com </td> </tr> <tr class="group" > <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > 10 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > User 10 </td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" > user10@example.com </td> </tr> </tbody> </table> </div> </div></div>
Table with custom classes
Custom classes will not be passes at the top level div, but to the first
child. The reason is to keep the div.flow-root
cleared of any custom
classes.
This example showcases the sticky header feature when you pass a max height class to the component.
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
<%# slim= render Vitrail::Table.new(class: "max-h-[28rem]") do |table| = table.with_header.with_content("id") = table.with_header.with_content("name") = table.with_header.with_content("email") - users.each do |user| - table.with_row do |row| = row.with_division.with_content(user.id) = row.with_division.with_content(user.name) = row.with_division.with_content(user.email)%><%= render Vitrail::Table.new(class: "max-h-[28rem]") do |table| %> <%= table.with_header.with_content("#") %> <%= table.with_header.with_content("Name") %> <%= table.with_header.with_content("Email") %> <% users.each do |user| %> <% table.with_row do |row| %> <%= row.with_division.with_content(user.id) %> <%= row.with_division.with_content(user.name) %> <%= row.with_division.with_content(user.email) %> <% end %> <% end %><% end %>