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
<div class="p-8">
<p class="text-sm text-gray-6 mb-4 font-mono">
pagy.page = 3  |  pagy.pages = 12
</p>
<nav class="midwest-pagination variant-default" aria-label="Pagination" data-controller="midwest-pagination" data-midwest-pagination-url-template-value="/posts?page=__PAGE__">
<div class="midwest-pagination-controls">
<a class="midwest-pagination-btn is-prev" aria-label="Go to previous page" href="/posts?page=2">
<div class="midwest-icon " aria-hidden="true">
<div class="midwest-icon-inner">
<svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" role="img" aria-label="Arrow back"><title>Arrow back</title>
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M244 400L100 256l144-144M120 256h292"></path></svg>
</div>
</div>
</a>
<a class="midwest-pagination-btn" aria-label="Go to page 1" href="/posts?page=1">1</a>
<a class="midwest-pagination-btn" aria-label="Go to page 2" href="/posts?page=2">2</a>
<span class="midwest-pagination-btn is-current" aria-current="page">3</span>
<a class="midwest-pagination-btn" aria-label="Go to page 4" href="/posts?page=4">4</a>
<a class="midwest-pagination-btn" aria-label="Go to page 5" href="/posts?page=5">5</a>
<span class="midwest-pagination-ellipsis" aria-hidden="true"></span>
<a class="midwest-pagination-btn" aria-label="Go to page 12" href="/posts?page=12">12</a>
<a class="midwest-pagination-btn is-next" aria-label="Go to next page" href="/posts?page=4">
<div class="midwest-icon " aria-hidden="true">
<div class="midwest-icon-inner">
<svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" role="img" aria-label="Arrow forward"><title>Arrow forward</title>
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M268 112l144 144-144 144M392 256H100"></path></svg>
</div>
</div>
</a> </div>
<div class="midwest-pagination-footer">
<form class="midwest-pagination-jump" data-action="submit->midwest-pagination#jump">
<label for="page-jump-13588">Page</label>
<input type="number" id="page-jump-13588" autocomplete="off" min="1" max="12" value="3" data-midwest-pagination-target="jumpInput">
<button type="submit">Go</button>
</form>
<div class="midwest-pagination-per-page">
<label for="per-page-13588">Rows per page</label>
<select id="per-page-13588" data-action="change->midwest-pagination#navigate">
<option value="/posts?per_page=10&page=1" >
10
</option>
<option value="/posts?per_page=25&page=1" selected>
25
</option>
<option value="/posts?per_page=50&page=1" >
50
</option>
</select>
</div>
</div>
</nav>
</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
<%
# In a real app, `pagy` comes from the controller via `pagy(collection)`.
# Here we build a plain struct that mirrors the Pagy public API so this
# preview works without adding the pagy gem to the host application.
#
# Pagy key attributes:
# pagy.page => current page (Integer)
# pagy.pages => total number of pages (Integer)
#
# Typical controller setup:
#
# include Pagy::Backend
#
# def index
# @pagy, @posts = pagy(Post.all)
# end
#
# Typical view integration:
#
# midwest_pagination(
# current_page: @pagy.page,
# total_pages: @pagy.pages,
# page_url: ->(p) { pagy_url_for(@pagy, p) }
# )
pagy = Struct.new(:page, :pages, keyword_init: true).new(page: 3, pages: 12)
%>
<div class="p-8">
<p class="text-sm text-gray-6 mb-4 font-mono">
pagy.page = <%= pagy.page %>  |  pagy.pages = <%= pagy.pages %>
</p>
<%= midwest_pagination(
current_page: pagy.page,
total_pages: pagy.pages,
per_page: 25,
page_url: ->(p) { "/posts?page=#{p}" },
per_page_url: ->(n) { "/posts?per_page=#{n}&page=1" },
show_jump_to: true,
show_per_page: true
) %>
</div>

No assets to display.
Add a .js or .css file alongside the component to see it here.

Accessibility

Figma embed for Pagination/pagy

Annotate a preview to embed its Figma design here:

@figma "https://figma.com/..."