Skip to content

Instantly share code, notes, and snippets.

@deeshrestha
Created December 6, 2018 18:20
Show Gist options
  • Save deeshrestha/362490aead2fc4b2fd15c3aae24254cf to your computer and use it in GitHub Desktop.
Save deeshrestha/362490aead2fc4b2fd15c3aae24254cf to your computer and use it in GitHub Desktop.
Bulma Blade Template For Laravel 5.7 Pagination
{{--
Laravel's default pagination html tags modifed to make Bulma CSS compatible paginator.
1. First run "php artisan vendor:publish --tag=laravel-pagination"
2. This command will place the views in the resources/views/vendor/pagination directory.
3. Replace text on "bootstrap-4.blade.php" with this code.
4. Remove other blade files if not needed (optional).
--}}
@if ($paginator->hasPages())
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<a class="pagination-previous" disabled>Previous</a>
@else
<a class="pagination-previous" href="{{ $paginator->previousPageUrl() }}">Previous</a>
@endif
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<a class="pagination-next" href="{{ $paginator->nextPageUrl() }}">Next Page</a>
@else
<a class="pagination-next" disabled>Next Page</a>
@endif
{{-- Pagination Elements --}}
<ul class="pagination-list">
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li><span class="pagination-ellipsis">&hellip;</span></li>
@endif
{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li><a class="pagination-link is-current" aria-label="Goto page {{ $page }}">{{ $page }}</a></li>
@else
<li><a href="{{ $url }}" class="pagination-link" aria-label="Goto page {{ $page }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach
</ul>
</nav>
@endif
@pvguerra
Copy link

Thanks!

Still works on Laravel 8, but now the file to replace the code is tailwind.blade.php

@de-raaf-media
Copy link

To use the language file replace Previous and Next with:
@lang('pagination.previous')
@lang('pagination.next')

You can also specify the template to use in the links() call. For example {{ $posts->links('pagination.bulma') }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment