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
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
<div class="max-w-4xl mx-auto p-6 space-y-10"> <div> <h2 class="text-xl font-bold mb-4">Table inside a Card (bordered)</h2> <p class="text-sm text-grayscale-500 mb-4"> Use <code>body_padding: false</code> on the Card and <code>container_classes: "shadow-none ring-0 rounded-none"</code> on the Table to avoid double card styling. </p> <div class="flex flex-col rounded-lg text-base bg-white border border-primary-300 text-grayscale-900 shadow-sm" > <div class="p-6 border-b border-primary-200"> Team Members </div> <div class=""> <div class="ring-black/5 sm:rounded-lg overflow-x-auto shadow-none ring-0 rounded-none"> <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" scope="col" > Name </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" > Email </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-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col" > Status </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-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" > Active </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-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" > Active </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-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" > Inactive </td> </tr> </tbody> </table> </div> </div> <div class="p-6 border-t border-primary-200"> <div class="flex justify-between items-center"> <span class="text-sm text-grayscale-500">3 members</span> <button class="text-sm text-primary-600 font-medium hover:text-primary-800">Add member</button> </div> </div> </div> </div> <div> <h2 class="text-xl font-bold mb-4">Table inside a Card (outline, success variant)</h2> <div class="flex flex-col rounded-lg text-base bg-white border-2 border-success-500 text-success-700 shadow-sm" > <div class="p-6 border-b border-success-500"> <div class="flex justify-between items-center"> <span class="font-semibold">Recent Orders</span> <span class="text-xs bg-success-100 text-success-700 px-2 py-1 rounded-full">Live</span> </div> </div> <div class=""> <div class="ring-black/5 sm:rounded-lg overflow-x-auto shadow-none ring-0 rounded-none"> <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" scope="col" > Order # </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" > Customer </th> <th class="px-3 py-3.5 text-sm font-semibold align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col" > Amount </th> </tr> </thead> <tbody class="divide-y divide-success-200 bg-white"> <tr class="even:bg-success-50 hover:bg-success-100 transition-colors"> <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" > #1001 </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" > Jane Cooper </td> <td class="px-3 py-4 text-sm text-black align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" > $120.00 </td> </tr> <tr class="even:bg-success-50 hover:bg-success-100 transition-colors"> <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" > #1002 </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" > Wade Warren </td> <td class="px-3 py-4 text-sm text-black align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" > $89.50 </td> </tr> <tr class="even:bg-success-50 hover:bg-success-100 transition-colors"> <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" > #1003 </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" > Esther Howard </td> <td class="px-3 py-4 text-sm text-black align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" > $245.00 </td> </tr> </tbody> </table> </div> </div> </div> </div> <div> <h2 class="text-xl font-bold mb-4">Collection mode inside a Card (soft, info variant)</h2> <div class="flex flex-col rounded-lg text-base bg-info-50 border border-info-100 text-info-800 shadow-sm" > <div class="p-6 border-b border-info-100"> <span class="font-semibold">Product Inventory</span> </div> <div class=""> <div class="ring-black/5 sm:rounded-lg overflow-x-auto shadow-none ring-0 rounded-none"> <table class="min-w-full divide-y divide-info-300"> <thead class="bg-info-50 text-info-900"> <tr> <th class="px-3 py-2 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"> Product </th> <th class="px-3 py-2 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"> SKU </th> <th class="px-3 py-2 text-sm font-semibold align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col"> Price </th> <th class="px-3 py-2 text-sm font-semibold align-middle text-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6" scope="col"> Stock </th> </tr> </thead> <tbody class="divide-y divide-info-200 bg-white"> <tr class="hover:bg-info-100 transition-colors"> <td class="px-3 py-2.5 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">Widget A</td> <td class="px-3 py-2.5 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">WA-001</td> <td class="px-3 py-2.5 text-sm text-black align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">$29.99</td> <td class="px-3 py-2.5 text-sm text-black align-middle text-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">142</td> </tr> <tr class="hover:bg-info-100 transition-colors"> <td class="px-3 py-2.5 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">Widget B</td> <td class="px-3 py-2.5 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">WB-002</td> <td class="px-3 py-2.5 text-sm text-black align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">$49.99</td> <td class="px-3 py-2.5 text-sm text-black align-middle text-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">38</td> </tr> <tr class="hover:bg-info-100 transition-colors"> <td class="px-3 py-2.5 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">Gadget C</td> <td class="px-3 py-2.5 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">GC-003</td> <td class="px-3 py-2.5 text-sm text-black align-middle text-right first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">$99.99</td> <td class="px-3 py-2.5 text-sm text-black align-middle text-center first:ps-4 first:pe-3 sm:first:ps-6 last:ps-3 last:pe-4 sm:last:pe-6">7</td> </tr> </tbody> </table> </div> </div> <div class="p-6 border-t border-info-100"> <span class="text-sm text-grayscale-500">Showing 3 of 3 products</span> </div> </div> </div> <div> <h2 class="text-xl font-bold mb-4">Standalone table (for comparison)</h2> <p class="text-sm text-grayscale-500 mb-4"> The table renders with its own card styling by default. </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" scope="col" > Name </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" > Email </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-primary-200 bg-white"> <tr class="hover:bg-primary-100 transition-colors"> <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="hover:bg-primary-100 transition-colors"> <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> </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
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
<div class="max-w-4xl mx-auto p-6 space-y-10"> <%# ===== 1. Table inside a bordered Card ===== %> <div> <h2 class="text-xl font-bold mb-4">Table inside a Card (bordered)</h2> <p class="text-sm text-grayscale-500 mb-4"> Use <code>body_padding: false</code> on the Card and <code>container_classes: "shadow-none ring-0 rounded-none"</code> on the Table to avoid double card styling. </p> <%= render BetterUi::CardComponent.new( style: :bordered, variant: :primary, body_padding: false ) do |card| %> <% card.with_header { "Team Members" } %> <% card.with_body do %> <%= render BetterUi::Table::TableComponent.new( variant: :primary, container_classes: "shadow-none ring-0 rounded-none" ) do |t| %> <% t.with_header do |h| %> <% h.with_cell(label: "Name") %> <% h.with_cell(label: "Email") %> <% h.with_cell(label: "Role") %> <% h.with_cell(label: "Status", align: :center) %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "Alice Johnson" } %> <% r.with_cell { "alice@example.com" } %> <% r.with_cell { "Admin" } %> <% r.with_cell(align: :center) { "Active" } %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "Bob Smith" } %> <% r.with_cell { "bob@example.com" } %> <% r.with_cell { "Editor" } %> <% r.with_cell(align: :center) { "Active" } %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "Charlie Brown" } %> <% r.with_cell { "charlie@example.com" } %> <% r.with_cell { "Viewer" } %> <% r.with_cell(align: :center) { "Inactive" } %> <% end %> <% end %> <% end %> <% card.with_footer do %> <div class="flex justify-between items-center"> <span class="text-sm text-grayscale-500">3 members</span> <button class="text-sm text-primary-600 font-medium hover:text-primary-800">Add member</button> </div> <% end %> <% end %> </div> <%# ===== 2. Table inside an outline Card ===== %> <div> <h2 class="text-xl font-bold mb-4">Table inside a Card (outline, success variant)</h2> <%= render BetterUi::CardComponent.new( variant: :success, style: :outline, body_padding: false ) do |card| %> <% card.with_header do %> <div class="flex justify-between items-center"> <span class="font-semibold">Recent Orders</span> <span class="text-xs bg-success-100 text-success-700 px-2 py-1 rounded-full">Live</span> </div> <% end %> <% card.with_body do %> <%= render BetterUi::Table::TableComponent.new( variant: :success, striped: true, hoverable: true, container_classes: "shadow-none ring-0 rounded-none" ) do |t| %> <% t.with_header do |h| %> <% h.with_cell(label: "Order #") %> <% h.with_cell(label: "Customer") %> <% h.with_cell(label: "Amount", align: :right) %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "#1001" } %> <% r.with_cell { "Jane Cooper" } %> <% r.with_cell(align: :right) { "$120.00" } %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "#1002" } %> <% r.with_cell { "Wade Warren" } %> <% r.with_cell(align: :right) { "$89.50" } %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "#1003" } %> <% r.with_cell { "Esther Howard" } %> <% r.with_cell(align: :right) { "$245.00" } %> <% end %> <% end %> <% end %> <% end %> </div> <%# ===== 3. Collection mode inside a soft Card ===== %> <div> <h2 class="text-xl font-bold mb-4">Collection mode inside a Card (soft, info variant)</h2> <% products = [ { name: "Widget A", sku: "WA-001", price: "$29.99", stock: 142 }, { name: "Widget B", sku: "WB-002", price: "$49.99", stock: 38 }, { name: "Gadget C", sku: "GC-003", price: "$99.99", stock: 7 }, ] %> <%= render BetterUi::CardComponent.new( variant: :info, style: :soft, body_padding: false ) do |card| %> <% card.with_header do %> <span class="font-semibold">Product Inventory</span> <% end %> <% card.with_body do %> <%= render BetterUi::Table::TableComponent.new( collection: products, variant: :info, size: :sm, hoverable: true, container_classes: "shadow-none ring-0 rounded-none" ) do |t| %> <% t.with_column(key: :name, label: "Product") %> <% t.with_column(key: :sku, label: "SKU") %> <% t.with_column(key: :price, label: "Price", align: :right) %> <% t.with_column(key: :stock, label: "Stock", align: :center) { |p| p[:stock].to_s } %> <% end %> <% end %> <% card.with_footer do %> <span class="text-sm text-grayscale-500">Showing 3 of 3 products</span> <% end %> <% end %> </div> <%# ===== 4. Standalone table for comparison ===== %> <div> <h2 class="text-xl font-bold mb-4">Standalone table (for comparison)</h2> <p class="text-sm text-grayscale-500 mb-4"> The table renders with its own card styling by default. </p> <%= render BetterUi::Table::TableComponent.new(variant: :primary, hoverable: true) do |t| %> <% t.with_header do |h| %> <% h.with_cell(label: "Name") %> <% h.with_cell(label: "Email") %> <% h.with_cell(label: "Role") %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "Alice Johnson" } %> <% r.with_cell { "alice@example.com" } %> <% r.with_cell { "Admin" } %> <% end %> <% t.with_row do |r| %> <% r.with_cell { "Bob Smith" } %> <% r.with_cell { "bob@example.com" } %> <% r.with_cell { "Editor" } %> <% end %> <% end %> </div></div>No notes provided.
No params configured.