i tried to use twitter bootstrap in Laravel 8, but after manual, bootstrap JS(?) dont work. CSS are loaded and styles work but dropdowns etc not. When i hit dropdown menu item nothin happen.
I did:
composer require laravel/ui
php artisan ui bootstrap
npm install
npm run watch / dev
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<script src="{{ mix('js/app.js') }}"></script>
However when i insert just CDN links everythin works ofc. What did i wrong?
I created new app and have same issue.
Laravel v8.28.1, tried like 5 bootstrap/laravel tutorials, always same result.
3
Answers
Ok i did it, the problem wasnt JS, but bootstrap versions. Laravel ui bootstrap installs 4.0 and examples (i copypasted menu example) on bootstrap page are dedicated now for bootstrap 5 beta where
data-toggle="dropdown"
has been changed todata-bs-toggle="dropdown"
as i see.complete tutorial to follow: (you need to compile JavaScript)
https://www.positronx.io/how-to-properly-install-and-use-bootstrap-in-laravel/
for the same following are the steps for same
Installation
The Bootstrap and Vue scaffolding provided by Laravel is located in the laravel/ui Composer package, which may be installed using Composer:
Once the laravel/ui package has been installed, you may install the frontend scaffolding using the ui Artisan command:
Before compiling your CSS, install your project’s frontend dependencies using the Node package manager (NPM):
Once the dependencies have been installed using npm install, you can compile your SASS files to plain CSS using Laravel Mix. The npm run dev command will process the instructions in your webpack.mix.js file. Typically, your compiled CSS will be placed in the public/css directory:
The webpack.mix.js file included with Laravel’s frontend scaffolding will compile the resources/sass/app.scss SASS file. This app.scss file imports a file of SASS variables and loads Bootstrap, which provides a good starting point for most applications. Feel free to customize the app.scss file however you wish or even use an entirely different pre-processor by configuring Laravel Mix.