Prerequisites
Before starting the project make sure to install the following utilities:
Creating a new Laravel application
Let's create a fresh Laravel application so that we can go through all the steps together.
composer install --ignore-platform-req=ext-fileinfo
or
composer update --ignore-platform-reqs
.
Step 1
Create new project.
Step 2
Run the development server.
Installing and configuring Tailwind CSS and TW Elements
Step 1
Install Tailwind CSS.
File structure
If you have followed all instructions mentioned earlier, your file structure should look like this:
Step 2
Add the paths to all of your template files in your
tailwind.config.js
file.
Step 3
Add the @tailwind
directives for each of Tailwind’s layers to
your app.css
file.
Step 4
Make sure your compiled CSS and JS are included in the
head
in welcome.blade.php
file.
Step 5
Install TW Elements.
Step 6
Import and initialize with initTWE
function components which
are you intend to use and necessary function initTWE
in
app.js
. Additionally add HTML markup for components in the
welcome.blade.php
file.
Step 7
Start build process.
And run the development server. Awesome! You're all set to dive into using TW Elements for your Laravel project. Have fun!
Initializing via JS
By default all components have autoinit which means they are initialized by data attributes. But if you want to make init by JavaScript - there is also possibility to do that.
Step 1
Import and initialize components.