How to install Selectize.JS in Laravel 9

Today we will learn How to install Selectize.JS in Laravel 9. Selectize is an extensible jQuery-based custom UI control. It’s useful for tagging, contact lists, country selectors, and so on. It clocks in at around ~7kb (gzipped). The goal is to provide a solid & usable experience with a clean and powerful API.

Also Read : How to Create a User using tinker in laravel 9

Install Selectize.JS Using NPM :

To Install Selectize.JS using npm you have to run a command:

npm install selectize --save

that will add the package to you package.json dependencies.

After that open bootstrap.js or app.js and add the following line :

window.selectize = require('selectize');

Or if you just want to load the js, something like

require('selectize/dist/selectize.js'); 

that its you have to now run the following command:

npm run dev

or

npm run production

Also Read : React & Tailwind CSS – Reusable Button Component

Install Using CDN :

The simple way to install Selectize.js in Laravel 9 is using CDN.

For that you just have to add CSS and JS file to your head section of website.

CSS:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.13.5/css/selectize.min.css"/>

JS:

<script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.13.5/js/selectize.min.js" ></script>

Please note add script file after jQuery script only. In head or one line before body close.

Now, you can use Selectize.js into your project its installed!

If you have any query or suggestion please let me know in comment section!

Also Read : How to Install Alpine.js in Laravel 9

4 Comments

Leave a Reply