Created
November 5, 2017 12:54
-
-
Save mazedlx/86512703b1dbcb987b2815c31e5173a3 to your computer and use it in GitHub Desktop.
Tailwind CSS template for Laravel pagination
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
@if ($paginator->hasPages()) | |
<div class="flex items-center"> | |
{{-- Previous Page Link --}} | |
@if ($paginator->onFirstPage()) | |
<span class="rounded-l rounded-sm border border-brand-light px-3 py-2 cursor-not-allowed no-underline">«</span> | |
@else | |
<a | |
class="rounded-l rounded-sm border-t border-b border-l border-brand-light px-3 py-2 text-brand-dark hover:bg-brand-light no-underline" | |
href="{{ $paginator->previousPageUrl() }}" | |
rel="prev" | |
> | |
« | |
</a> | |
@endif | |
{{-- Pagination Elements --}} | |
@foreach ($elements as $element) | |
{{-- "Three Dots" Separator --}} | |
@if (is_string($element)) | |
<span class="border-t border-b border-l border-brand-light px-3 py-2 cursor-not-allowed no-underline">{{ $element }}</span> | |
@endif | |
{{-- Array Of Links --}} | |
@if (is_array($element)) | |
@foreach ($element as $page => $url) | |
@if ($page == $paginator->currentPage()) | |
<span class="border-t border-b border-l border-brand-light px-3 py-2 bg-brand-light no-underline">{{ $page }}</span> | |
@else | |
<a class="border-t border-b border-l border-brand-light px-3 py-2 hover:bg-brand-light text-brand-dark no-underline" href="{{ $url }}">{{ $page }}</a> | |
@endif | |
@endforeach | |
@endif | |
@endforeach | |
{{-- Next Page Link --}} | |
@if ($paginator->hasMorePages()) | |
<a class="rounded-r rounded-sm border border-brand-light px-3 py-2 hover:bg-brand-light text-brand-dark no-underline" href="{{ $paginator->nextPageUrl() }}" rel="next">»</a> | |
@else | |
<span class="rounded-r rounded-sm border border-brand-light px-3 py-2 hover:bg-brand-light text-brand-dark no-underline cursor-not-allowed">»</span> | |
@endif | |
</div> | |
@endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To any who doesn't want to use bootstrap or tailwindcss you can use this to customize Laravel pagination. this is a scss style.
.pagination{
margin: 5px;
.px-4 {padding-left: 1rem; padding-right: 1rem;}
.px-2 {padding-left: 0.5rem; padding-right: 0.5rem;}
.py-2 {padding-top: 0.5rem; padding-bottom: 0.5rem;}
.ml {margin-left: 3px;}
.ml-3 {margin-left: 0.75rem;}
.-ml-px {margin-left: -1px;}
.w-5 {width: 1.25rem}
.h-5 {height: 1.25rem}
.text-sm {font-size: 0.875rem;}
.font-medium {font-weight: 500;}
.border {border: 1px solid;}
.cursor-default {cursor: default;}
.leading-5 {line-height: 1.25rem;}
.rounded-md {border-radius: 0.375rem;}
.rounded-1-md {
border-top-left-radius: 0.375rem;
border-bottom-left-radius: 0.375rem;
}
.flex {display: flex;}
.items-center {align-items: center;}
.justify-between {justify-content: space-between;}
.flex-1 {flex: 1;}
.inline-flex {display: inline-flex;}
.items-center {justify-items: center;}
.border-gray-300 {border-color: rgba(209, 213, 219, 100);}
.text-gray-700 {color:rgba(55, 65, 81, 1);}
.text-gray-500 {color: rgba(107, 114, 128, 1)}
.z-0 {z-index: 0;}
.relative {position: relative;}
.bg-white {background: white;}
.sm:hidden {display: none;}
} // end pagination