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
<div class="p-8"> <p class="mb-4 text-sm text-gray-6"> Click a header to sort by it; Shift-click to add a secondary sort. </p> <turbo-frame id="multi-sort-demo"> <div data-controller="midwest-table" data-midwest-table-resizable-value="false" class="midwest-table-wrapper"> <div class="midwest-table-loading-overlay" aria-hidden="true"> <div class="midwest-loading-icon" role="img" aria-label="Loading" decorative="true"> <div class="midwest-loading-icon-inner"> <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <svg viewbox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="Midwest-LoadingIcon__Svg" focusable="false" aria-hidden="true"> <circle cx="15" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="60" cy="15" r="9" fill-opacity="0.3"> <animate attributename="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="105" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> </svg> </div> </div> </div> <div class="midwest-table-scroll"> <table class="midwest-table"> <caption class="sr-only">Team</caption> <thead class="midwest-table-head"> <tr> <th scope="col" class="midwest-table-th align-start sortable" aria-sort="none" data-col-index="0"> <a class="midwest-table-sort-link" href="?sort=role" data-multi-sort-url="?sort=role,name" data-action="click->midwest-table#sortColumn"> Role <span class="midwest-table-sort-icon" aria-hidden="true"></span> </a></th> <th scope="col" class="midwest-table-th align-start sortable" aria-sort="none" data-col-index="1"> <a class="midwest-table-sort-link" href="?sort=name" data-multi-sort-url="?sort=role,name" data-action="click->midwest-table#sortColumn"> Name <span class="midwest-table-sort-icon" aria-hidden="true"></span> </a></th> </tr> </thead> <tbody class="midwest-table-body"> <tr class="midwest-table-row"> <td class="midwest-table-td align-start"> Engineer </td> <td class="midwest-table-td align-start"> Alice Johnson </td> </tr> <tr class="midwest-table-row"> <td class="midwest-table-td align-start"> Designer </td> <td class="midwest-table-td align-start"> Bob Smith </td> </tr> <tr class="midwest-table-row"> <td class="midwest-table-td align-start"> Manager </td> <td class="midwest-table-td align-start"> Carol White </td> </tr> </tbody> </table> </div> </div> </turbo-frame></div>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<% row_class = Struct.new(:name, :role, keyword_init: true) rows = [ row_class.new(name: 'Alice Johnson', role: 'Engineer'), row_class.new(name: 'Bob Smith', role: 'Designer'), row_class.new(name: 'Carol White', role: 'Manager'), ]%><div class="p-8"> <p class="mb-4 text-sm text-gray-6"> Click a header to sort by it; Shift-click to add a secondary sort. </p> <turbo-frame id="multi-sort-demo"> <%= midwest_table(collection: rows, caption: 'Team') do |t| %> <% t.with_column('Role', key: :role, sortable: true, sort_url: '?sort=role', multi_sort_url: '?sort=role,name') %> <% t.with_column('Name', key: :name, sortable: true, sort_url: '?sort=name', multi_sort_url: '?sort=role,name') %> <% end %> </turbo-frame></div>Multi-column sort
Click a sortable header to sort by that column; hold Shift and click to add
it as a secondary sort (shown with a priority badge). Wired automatically by
midwest_table_from / TurboTable; here the sort URLs are set by hand.
No params configured.
No assets to display.
Add a .js or .css file alongside the component to see it here.
Figma embed for Table/multi_sort
Annotate a preview to embed its Figma design here:
@figma "https://figma.com/..."