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

Laravel 11.30 Introduces HasUniqueStringIds for Simple Unique IDs

Laravel 11.30 Introduces HasUniqueStringIds for Simple Unique IDs

Laravel 11.30 Introduces HasUniqueStringIds for Simple Unique IDs

1 month ago Read article →
Laravel custom login and register Tutorial

Laravel custom login and register Tutorial

Laravel custom login and register Tutorial

1 month ago Read article →
Per-Second Rate Limiting in Laravel 11

Per-Second Rate Limiting in Laravel 11

Per-Second Rate Limiting in Laravel 11

1 month ago Read article →
Multi-Guard Authentication with Laravel Fortify

Multi-Guard Authentication with Laravel Fortify

Multi-Guard Authentication with Laravel Fortify

1 month ago Read article →