'Tailwind laravel pagination doesn't work properly
So, I'm creating a project using laravel and tailwind. After using the paginate() method and then this code in the view
@if ($posts->count())
@foreach ($posts as $post)
<div class="mb-4">
<a class="font-bold" href="">{{ $post->user->name }}</a> <span
class="text-gray-600 text-sm">{{ $post->created_at->diffForHumans() }}</span>
<p class="mb-2">{{ $post->description }}</p>
</div>
@endforeach
{{ $posts->links() }} (this line to create the link to other pages is not working properly)
@else
<p>There are no posts</p>
@endif
The pagination design was a little bizarre. Going to the next and previous page is working correctly.

Solution 1:[1]
I had the same problem. Wasn't able to fix it but found a workaround by using:
php artisan vendor:publish --tag=laravel-pagination
As described here: https://laravel.com/docs/8.x/pagination#customizing-the-pagination-view
The outputted resources/views/vendor/pagination/tailwind.blade.php file did have the correct css and looked good.
Solution 2:[2]
You can install npm i tailwindcss-plugins -D
Then register the plugin in your tailwind configuration.
plugins: [
require('tailwindcss-plugins/pagination')({
/* ... */
}),
],
And then you can use this in your blade:
{{ $items->links() }}
Solution 3:[3]
I also had the same problem and was able to solve it by using this command:
php artisan vendor:publish --tag=laravel-pagination
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | wadapatja |
| Solution 2 | |
| Solution 3 | ouflak |
