6

I'm building an app with Laravel 5.5. and I need to customize the pagination. I have to apply css class on the page link elements. Where I find the template to override?

3 Answers 3

14

You have to launch this command from terminal:

php artisan vendor:publish --tag=laravel-pagination

This creates the views in the resources/views/vendor/pagination directory.

Now you can apply your classes in the view: default.blade.php.

Read the documentation here: https://laravel.com/docs/5.6/pagination#customizing-the-pagination-view

Sign up to request clarification or add additional context in comments.

1 Comment

Nothing to publish for tag [laravel-pagination].
8

You can specify your own pagination view:

{{ $paginator->links('view.name') }}

From the docs:

By default, the views rendered to display the pagination links are compatible with the Bootstrap CSS framework. However, if you are not using Bootstrap, you are free to define your own views to render these links. When calling the links method on a paginator instance, pass the view name as the first argument to the method

Or you can customize the default view.

From the docs:

However, the easiest way to customize the pagination views is by exporting them to your resources/views/vendor directory using the vendor:publish command:

php artisan vendor:publish --tag=laravel-pagination

This command will place the views in the resources/views/vendor/pagination directory. The default.blade.php file within this directory corresponds to the default pagination view. Edit this file to modify the pagination HTML.

Or, if you've just modified default Bootstrap classes, you can just load CSS after Bootstrap is loaded.

Comments

3

You need to publish the views first with php artisan vendor:publish --tag=laravel-pagination then they will appear in your resources/views/vendor/pagination folder and you can override them. Here is the reference

This command will place the views in the resources/views/vendor/pagination directory. The default.blade.php file within this directory corresponds to the default pagination view. Simply edit this file to modify the pagination HTML.

2 Comments

You answered first tbh
Nothing to publish for tag [laravel-pagination].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.