Last active
April 21, 2022 01:07
-
-
Save gausoft/b67b0c871c6ca5f43a79b1dafdbe6ece to your computer and use it in GitHub Desktop.
Statamic CMS collections pagination styled with TailwindCSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ paginate }} | |
<ul class="pagination flex flex-row justify-center items-center"> | |
{{ if prev_page }} | |
<li> | |
<a href="{{ prev_page }}" | |
class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
<span class="sr-only">Préc.</span> | |
<!-- Heroicon name: solid/chevron-left --> | |
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" | |
aria-hidden="true"> | |
<path fill-rule="evenodd" | |
d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" | |
clip-rule="evenodd" /> | |
</svg> | |
</a> | |
</li> | |
{{ else }} | |
<li | |
class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
<span class="sr-only">Préc.</span> | |
<!-- Heroicon name: solid/chevron-left --> | |
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" | |
aria-hidden="true"> | |
<path fill-rule="evenodd" | |
d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" | |
clip-rule="evenodd" /> | |
</svg> | |
</li> | |
{{ /if }} | |
{{ links:segments }} | |
{{ first }} | |
{{ if page == current_page }} | |
<li | |
class="z-10 bg-indigo-50 border-indigo-500 text-indigo-600 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> | |
<span>{{ page }}</span> | |
</li> | |
{{ else }} | |
<li><a href="{{ url }}" | |
class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium">{{ | |
page }}</a></li> | |
{{ /if }} | |
{{ /first }} | |
{{ if slider }} | |
<span | |
class="relative inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-sm font-medium text-gray-700"> | |
... </span> | |
{{ /if }} | |
{{ slider }} | |
{{ if page == current_page }} | |
<li> | |
<a href="{{ url }}" | |
class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> | |
{{ page }} | |
</a> | |
</li> | |
{{ else }} | |
<li><a href="{{ url }}">{{ page }}</a></li> | |
{{ /if }} | |
{{ /slider }} | |
{{ if slider || (!slider && last) }} | |
<li class="disabled"> | |
<span | |
class="relative inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-sm font-medium text-gray-700"> | |
... </span> | |
</li> | |
{{ /if }} | |
{{ last }} | |
{{ if page == current_page }} | |
<li> | |
<a href="{{ url }}" | |
class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> | |
{{ page }} | |
</a> | |
</li> | |
{{ else }} | |
<li> | |
<a href="{{ url }}" | |
class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> | |
{{ page }} | |
</a> | |
</li> | |
{{ /if }} | |
{{ /last }} | |
{{ /links:segments }} | |
{{ if next_page }} | |
<li> | |
<a href="{{ next_page }}" | |
class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
<span class="sr-only">Suiv.</span> | |
<!-- Heroicon name: solid/chevron-right --> | |
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" | |
aria-hidden="true"> | |
<path fill-rule="evenodd" | |
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" | |
clip-rule="evenodd" /> | |
</svg> | |
</a> | |
</li> | |
{{ else }} | |
<li | |
class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
<span class="sr-only">Suiv.</span> | |
<!-- Heroicon name: solid/chevron-right --> | |
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" | |
aria-hidden="true"> | |
<path fill-rule="evenodd" | |
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" | |
clip-rule="evenodd" /> | |
</svg> | |
</li> | |
{{ /if }} | |
</ul> | |
{{ /paginate }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment