Your Guide to Laravel Excellence

Get Started with Bootstrap 5 in Laravel 11: A Step-by-Step Guide

Get Started with Bootstrap 5 in Laravel 11: A Step-by-Step Guide

How to Install Bootstrap in a Laravel Project

In this tutorial, we will learn how to install Bootstrap in a Laravel project. You can follow this guide to install it in multiple Laravel versions like Laravel 8, Laravel 9, Laravel 10, and Laravel 11. We will install it using npm and integrate it into the application using Vite for asset bundling.

Install Bootstrap and SASS

Run the following commands in your terminal to install Bootstrap and SASS:

npm install -D bootstrap@5.3.3

npm install -D sass

Import Bootstrap SCSS:

Create an SCSS file (e.g., resources/scss/app.scss ) if you haven't already, and import Bootstrap's SCSS file into it:

@import "../../node_modules/bootstrap/scss/bootstrap.scss";

Import Bootstrap SCSS:

Import Bootstrap's JavaScript functionality into your JavaScript file (e.g., resources/js/app.js ):

import './bootstrap';


import '../sass/app.scss';
import * as bootstrap from 'bootstrap';

Include Bundled Assets in Your Laravel Blade File

In your Laravel Blade file (e.g., resources/views/layouts/app.blade.php ), include the bundled CSS and JavaScript files:

@vite(['resources/scss/app.scss', 'resources/js/app.js'])

Output

Bootstrap installed in laravel 11

Recommeded Posts

Introduction to Multiple Authentication Guards in Laravel

Introduction to Multiple Authentication Guards in Laravel

Introduction to Multiple Authentication Guards in Laravel

4 months ago Read article →
Guide to Session Management and Flash Messages in Laravel

Guide to Session Management and Flash Messages in Laravel

Learn how to use Laravel's session management and flash messages. This comprehensive guide covers storing data, handling user states, and displaying temporary notifications in your Laravel applications.

4 months ago Read article →
New in Laravel 12: Eager Loading, Attribute Scopes, and fromJson

New in Laravel 12: Eager Loading, Attribute Scopes, and fromJson

Discover the new features in Laravel 12! Learn about automatic eager loading, easier query scopes with PHP attributes, and the new Collection::fromJson() method

4 months ago Read article →
How to Implement Custom Facebook OAuth Login in Laravel  Without Socialite

How to Implement Custom Facebook OAuth Login in Laravel Without Socialite

How to Implement Custom Facebook OAuth Login in Laravel Without Socialite

4 months ago Read article →