Previews

No matching results.

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
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
<div class="max-w-4xl mx-auto p-6">
<h2 class="text-xl font-bold mb-4">Sortable Headers (Slot Mode)</h2>
<p class="text-sm text-grayscale-500 mb-4">Headers can indicate sort state with directional icons.</p>
<div class="shadow-sm ring-1 ring-black/5 sm:rounded-lg overflow-x-auto">
<table class="min-w-full divide-y divide-primary-300">
<thead class="bg-primary-50 text-primary-900">
<tr class="">
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col" >
<span class="flex items-center gap-1">
Name
<span class="text-primary-700"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M11.78 9.78a.75.75 0 0 1-1.06 0L8 7.06 5.28 9.78a.75.75 0 0 1-1.06-1.06l3.25-3.25a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</span>
</th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col" >
<span class="flex items-center gap-1">
Email
<span class="text-grayscale-400"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M5.22 10.22a.75.75 0 0 1 1.06 0L8 11.94l1.72-1.72a.75.75 0 1 1 1.06 1.06l-2.25 2.25a.75.75 0 0 1-1.06 0l-2.25-2.25a.75.75 0 0 1 0-1.06ZM10.78 5.78a.75.75 0 0 1-1.06 0L8 4.06 6.28 5.78a.75.75 0 0 1-1.06-1.06l2.25-2.25a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</span>
</th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col" >
Role
</th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col" >
<span class="flex items-center gap-1">
Joined
<span class="text-primary-700"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" /></svg></span>
</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-primary-200 bg-white">
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Alice Johnson
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
alice@example.com
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Admin
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
2024-01-15
</td>
</tr>
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Bob Smith
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
bob@example.com
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Editor
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
2024-02-20
</td>
</tr>
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Charlie Brown
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
charlie@example.com
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Viewer
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
2024-03-10
</td>
</tr>
</tbody>
</table>
</div>
<h2 class="text-xl font-bold mb-4 mt-8">Sortable Headers (Collection Mode)</h2>
<p class="text-sm text-grayscale-500 mb-4">Sort indicators in collection mode columns.</p>
<div class="shadow-sm ring-1 ring-black/5 sm:rounded-lg overflow-x-auto">
<table class="min-w-full divide-y divide-info-300">
<thead class="bg-info-50 text-info-900">
<tr>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col">
<span class="flex items-center gap-1">
Name
<span class="text-info-700"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M11.78 9.78a.75.75 0 0 1-1.06 0L8 7.06 5.28 9.78a.75.75 0 0 1-1.06-1.06l3.25-3.25a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</span>
</th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col">
<span class="flex items-center gap-1">
Email
<span class="text-grayscale-400"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M5.22 10.22a.75.75 0 0 1 1.06 0L8 11.94l1.72-1.72a.75.75 0 1 1 1.06 1.06l-2.25 2.25a.75.75 0 0 1-1.06 0l-2.25-2.25a.75.75 0 0 1 0-1.06ZM10.78 5.78a.75.75 0 0 1-1.06 0L8 4.06 6.28 5.78a.75.75 0 0 1-1.06-1.06l2.25-2.25a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</span>
</th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col">
Role
</th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col">
<span class="flex items-center gap-1">
Joined
<span class="text-info-700"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" /></svg></span>
</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-info-200 bg-white">
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Alice Johnson</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">alice@example.com</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Admin</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">2024-01-15</td>
</tr>
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Bob Smith</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">bob@example.com</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Editor</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">2024-02-20</td>
</tr>
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Charlie Brown</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">charlie@example.com</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Viewer</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">2024-03-10</td>
</tr>
</tbody>
</table>
</div>
<h2 class="text-xl font-bold mb-4 mt-8">Sortable with Links (Slot Mode)</h2>
<p class="text-sm text-grayscale-500 mb-4">Sort headers wrapped in clickable links with sort_url.</p>
<div class="shadow-sm ring-1 ring-black/5 sm:rounded-lg overflow-x-auto">
<table class="min-w-full divide-y divide-success-300">
<thead class="bg-success-50 text-success-900">
<tr class="">
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col" >
<a data-turbo-frame="_top" class="flex items-center gap-1 no-underline text-inherit" href="?sort=name&direction=desc">
Name
<span class="text-success-700"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M11.78 9.78a.75.75 0 0 1-1.06 0L8 7.06 5.28 9.78a.75.75 0 0 1-1.06-1.06l3.25-3.25a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</a></th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col" >
<a class="flex items-center gap-1 no-underline text-inherit" href="?sort=email&direction=asc">
Email
<span class="text-grayscale-400"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M5.22 10.22a.75.75 0 0 1 1.06 0L8 11.94l1.72-1.72a.75.75 0 1 1 1.06 1.06l-2.25 2.25a.75.75 0 0 1-1.06 0l-2.25-2.25a.75.75 0 0 1 0-1.06ZM10.78 5.78a.75.75 0 0 1-1.06 0L8 4.06 6.28 5.78a.75.75 0 0 1-1.06-1.06l2.25-2.25a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</a></th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col" >
Role
</th>
</tr>
</thead>
<tbody class="divide-y divide-success-200 bg-white">
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Alice Johnson
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
alice@example.com
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Admin
</td>
</tr>
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Bob Smith
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
bob@example.com
</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" >
Editor
</td>
</tr>
</tbody>
</table>
</div>
<h2 class="text-xl font-bold mb-4 mt-8">Sortable with Links (Collection Mode + Table-level sort_url)</h2>
<p class="text-sm text-grayscale-500 mb-4">Table-level sort_url auto-generates links for all sortable columns, with sort_column deriving the sorted state.</p>
<div class="shadow-sm ring-1 ring-black/5 sm:rounded-lg overflow-x-auto">
<table class="min-w-full divide-y divide-accent-300">
<thead class="bg-accent-50 text-accent-900">
<tr>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col">
<a data-turbo-frame="_top" class="flex items-center gap-1 no-underline text-inherit" href="?sort=name&direction=desc">
Name
<span class="text-accent-700"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M11.78 9.78a.75.75 0 0 1-1.06 0L8 7.06 5.28 9.78a.75.75 0 0 1-1.06-1.06l3.25-3.25a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</a> </th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col">
<a data-turbo-frame="_top" class="flex items-center gap-1 no-underline text-inherit" href="?sort=email&direction=asc">
Email
<span class="text-grayscale-400"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M5.22 10.22a.75.75 0 0 1 1.06 0L8 11.94l1.72-1.72a.75.75 0 1 1 1.06 1.06l-2.25 2.25a.75.75 0 0 1-1.06 0l-2.25-2.25a.75.75 0 0 1 0-1.06ZM10.78 5.78a.75.75 0 0 1-1.06 0L8 4.06 6.28 5.78a.75.75 0 0 1-1.06-1.06l2.25-2.25a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</a> </th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col">
Role
</th>
<th class="px-3 py-3.5 text-sm font-semibold align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6 cursor-pointer select-none" scope="col">
<a data-turbo-frame="_top" class="flex items-center gap-1 no-underline text-inherit" href="?sort=joined&direction=asc">
Joined
<span class="text-grayscale-400"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path fill-rule="evenodd" d="M5.22 10.22a.75.75 0 0 1 1.06 0L8 11.94l1.72-1.72a.75.75 0 1 1 1.06 1.06l-2.25 2.25a.75.75 0 0 1-1.06 0l-2.25-2.25a.75.75 0 0 1 0-1.06ZM10.78 5.78a.75.75 0 0 1-1.06 0L8 4.06 6.28 5.78a.75.75 0 0 1-1.06-1.06l2.25-2.25a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" /></svg></span>
</a> </th>
</tr>
</thead>
<tbody class="divide-y divide-accent-200 bg-white">
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Alice Johnson</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">alice@example.com</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Admin</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">2024-01-15</td>
</tr>
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Bob Smith</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">bob@example.com</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Editor</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">2024-02-20</td>
</tr>
<tr class="">
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Charlie Brown</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">charlie@example.com</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">Viewer</td>
<td class="px-3 py-4 text-sm text-black align-middle text-left first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">2024-03-10</td>
</tr>
</tbody>
</table>
</div>
</div>
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
<div class="max-w-4xl mx-auto p-6">
<h2 class="text-xl font-bold mb-4">Sortable Headers (Slot Mode)</h2>
<p class="text-sm text-grayscale-500 mb-4">Headers can indicate sort state with directional icons.</p>
<%= render BetterUi::Table::TableComponent.new(variant: :primary) do |t| %>
<% t.with_header do |h| %>
<% h.with_cell(label: "Name", sortable: true, sorted: true, sort_direction: :asc) %>
<% h.with_cell(label: "Email", sortable: true) %>
<% h.with_cell(label: "Role") %>
<% h.with_cell(label: "Joined", sortable: true, sorted: true, sort_direction: :desc) %>
<% end %>
<% [
["Alice Johnson", "alice@example.com", "Admin", "2024-01-15"],
["Bob Smith", "bob@example.com", "Editor", "2024-02-20"],
["Charlie Brown", "charlie@example.com", "Viewer", "2024-03-10"]
].each do |row_data| %>
<% t.with_row do |r| %>
<% r.with_cell { row_data[0] } %>
<% r.with_cell { row_data[1] } %>
<% r.with_cell { row_data[2] } %>
<% r.with_cell { row_data[3] } %>
<% end %>
<% end %>
<% end %>
<h2 class="text-xl font-bold mb-4 mt-8">Sortable Headers (Collection Mode)</h2>
<p class="text-sm text-grayscale-500 mb-4">Sort indicators in collection mode columns.</p>
<%
users = [
::OpenStruct.new(name: "Alice Johnson", email: "alice@example.com", role: "Admin", joined: "2024-01-15"),
::OpenStruct.new(name: "Bob Smith", email: "bob@example.com", role: "Editor", joined: "2024-02-20"),
::OpenStruct.new(name: "Charlie Brown", email: "charlie@example.com", role: "Viewer", joined: "2024-03-10")
]
%>
<%= render BetterUi::Table::TableComponent.new(collection: users, variant: :info) do |t| %>
<% t.with_column(key: :name, label: "Name", sortable: true, sorted: true, sort_direction: :asc) %>
<% t.with_column(key: :email, label: "Email", sortable: true) %>
<% t.with_column(key: :role, label: "Role") %>
<% t.with_column(key: :joined, label: "Joined", sortable: true, sorted: true, sort_direction: :desc) %>
<% end %>
<h2 class="text-xl font-bold mb-4 mt-8">Sortable with Links (Slot Mode)</h2>
<p class="text-sm text-grayscale-500 mb-4">Sort headers wrapped in clickable links with sort_url.</p>
<%= render BetterUi::Table::TableComponent.new(variant: :success) do |t| %>
<% t.with_header do |h| %>
<% h.with_cell(label: "Name", sortable: true, sorted: true, sort_direction: :asc,
sort_url: "?sort=name&direction=desc",
sort_html: { data: { turbo_frame: "_top" } }) %>
<% h.with_cell(label: "Email", sortable: true,
sort_url: "?sort=email&direction=asc") %>
<% h.with_cell(label: "Role") %>
<% end %>
<% [
["Alice Johnson", "alice@example.com", "Admin"],
["Bob Smith", "bob@example.com", "Editor"]
].each do |row_data| %>
<% t.with_row do |r| %>
<% r.with_cell { row_data[0] } %>
<% r.with_cell { row_data[1] } %>
<% r.with_cell { row_data[2] } %>
<% end %>
<% end %>
<% end %>
<h2 class="text-xl font-bold mb-4 mt-8">Sortable with Links (Collection Mode + Table-level sort_url)</h2>
<p class="text-sm text-grayscale-500 mb-4">Table-level sort_url auto-generates links for all sortable columns, with sort_column deriving the sorted state.</p>
<%= render BetterUi::Table::TableComponent.new(
collection: users,
variant: :accent,
sort_column: :name,
sort_direction: :asc,
sort_url: ->(key, dir) { "?sort=#{key}&direction=#{dir}" },
sort_html: { data: { turbo_frame: "_top" } }
) do |t| %>
<% t.with_column(key: :name, label: "Name", sortable: true) %>
<% t.with_column(key: :email, label: "Email", sortable: true) %>
<% t.with_column(key: :role, label: "Role") %>
<% t.with_column(key: :joined, label: "Joined", sortable: true) %>
<% end %>
</div>