How to Install Bootstrap 5 in Laravel 11 with Vite?
In this post, I will show you how to install Bootstrap 5 in Laravel 11 using Vite. If you’re looking to integrate Bootstrap 5 with Vite in your Laravel 11 application, follow this step-by-step guide. By the end, you’ll have Bootstrap 5 up and running in your Laravel project.
Step 1 : Install Laravel 11
First, if you haven’t already created a Laravel application, you can do so with the following command:
composer create-project laravel/laravel example-app
Step 2 : Install Laravel UI Package
Next, install the Laravel UI package which allows for the integration of Bootstrap with authentication scaffolding. Run the following command:
composer require laravel/ui
Step 3 : Install Bootstrap
To add Bootstrap with authentication scaffolding, run :
composer require laravel/ui
Step 4 : Install Bootstrap Icons
To include Bootstrap Icons, run the following command:
npm install bootstrap-icons --save-dev
Now, import the Bootstrap Icons CSS in the resources/sass/app.scss
file:
/* resources/sass/app.scss */
/* Fonts */
@import url('https://fonts.bunny.net/css?family=Nunito');
/* Variables */
@import 'variables';
/* Bootstrap */
@import 'bootstrap/scss/bootstrap';
@import 'bootstrap-icons/font/bootstrap-icons.css';
Step 5 : Build CSS & JS Files
Build your CSS and JavaScript files by running the following commands:
npm install
npm run build
Step 6 : Use Bootstrap Classes
Now, update the welcome.blade.php
file to use Bootstrap classes. Here is an example:
{{ config('app.name', 'Laravel') }}
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
ItSolutionStuff.com Tutorial
Laravel/Vite Bootstrap 5 Example
This simple jumbotron example is based on one of the official Bootstrap 5 examples.
View on getbootstrap.com
Some borders
Step 6 : Run Laravel App
Finally, run the Laravel application with the following command :
Open your web browser and navigate to http://localhost:8000/
to see your app in action.
php artisan serve
Conclusion :
By following these steps, you should have successfully installed Bootstrap 5 in your Laravel 11 application using Vite. This setup will help you leverage the powerful features of Bootstrap 5 and Vite in your Laravel projects.
Feel free to share your thoughts or questions in the comments below. Happy coding!