Skip to main content

Fix Laravel Pagination Style Problem

To fix the issue with Laravel (8, 9, and 10) UI pagination, you need to ensure that you have the necessary code in your AppServiceProvider to use the Bootstrap pagination style. Here are the steps to fix the problem:

  1. Open the App\Providers\AppServiceProvider file in your Laravel project.
  2. At the top of the file, add the following import statement:
   use Illuminate\Pagination\Paginator;
  1. Inside the boot method of the AppServiceProvider class, add the following line of code:
   Paginator::useBootstrap();

This line of code sets the pagination view to use the Bootstrap style.

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use Illuminate\Pagination\Paginator;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        //
        Schema::defaultStringLength(191);
        Paginator::useBootstrap();
    }
}
  1. Save the changes and close the file.

After making these changes, Laravel’s pagination should use the Bootstrap styling, which should resolve the issue with messy pagination in Laravel 8, 9, and 10 UI.

If you’re still experiencing issues, you can try this code in blade file:

$posts->links('pagination::bootstrap-4');

By continuing to use the site, you agree to the use of cookies.