How to install Flowbite and Tailwind CSS with Laravel

In this guide you will learn how to install and work with Laravel, Tailwind CSS, and Flowbite.

Flowbite is a popular open source component library built on top the utility-first Tailwind CSS framework including UI components such as dropdowns, modals,…


This content originally appeared on DEV Community and was authored by Zoltán Szőgyényi

In this guide you will learn how to install and work with Laravel, Tailwind CSS, and Flowbite.

Flowbite is a popular open source component library built on top the utility-first Tailwind CSS framework including UI components such as dropdowns, modals, buttons, and more.

Laravel is the most popular PHP web framework based on the model-view-controller (MCV) model that helps you build modern web applications and API's.

Install Tailwind CSS with Laravel

Follow the next steps to install Tailwind CSS and Flowbite with Laravel Mix.

Make sure that you have Composer and Node.js installed locally on your computer.

Require the Laravel Installer globally using Composer.

composer global require laravel/installer

Make sure to place the vendor bin directory in your PATH. Here's how you can do it based on each OS:

  • macOS: export PATH="$PATH:$HOME/.composer/vendor/bin"
  • Windows: set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
  • Linux: export PATH="~/.config/composer/vendor/bin:$PATH"

Create a new project using Laravel's CLI:

laravel new awesome-project

cd awesome-project

You can now access the Laravel application on http://localhost:8000.

This command will initialize a blank Laravel project that you can get started with.

Install Tailwind CSS and Flowbite using NPM:

npm install -D tailwindcss postcss autoprefixer @themesberg/flowbite

Create a Tailwind CSS config file:

npx tailwindcss init

A new tailwind.config.js file will be created inside your root folder.

Add the view paths and require Flowbite as a plugin inside tailwind.config.js:

module.exports = {
    content: [
      "./resources/**/*.blade.php",
      "./resources/**/*.js",
      "./resources/**/*.vue",
      "./node_modules/@themesberg/flowbite/**/*.js"
    ],
    theme: {
      extend: {},
    },
    plugins: [
        require('@themesberg/flowbite/plugin')
    ],
  }

Add Tailwind CSS to your Laravel Mix configuration by requiring it inside the webpack.mix.js file:

mix.js("resources/js/app.js", "public/js")
  .postCss("resources/css/app.css", "public/css", [

    // add here
    require("tailwindcss"),

  ]);

Add the directives inside the ./resources/css/app.css file:

@tailwind base;
@tailwind components;
@tailwind utilities;

Include the app.css file inside the <head> tag of your view templates:

<link href="/css/app.css" rel="stylesheet">

Require the flowbite.bundle.js file before the end of the <body> tag:

<script src="../path/to/@themesberg/flowbite/dist/flowbite.bundle.js"></script>

Alternatively, you can also include the JavaScript file using CDN:

<script src="https://unpkg.com/@themesberg/flowbite@{{< current_version >}}/dist/flowbite.bundle.js"></script>

Now that you've set everything up start up a local development server using php artisan serve and run the build process for Webpack by using npm run watch.

Flowbite components

Now that you have successfully installed the project you can start using the UI components from Flowbite and Tailwind CSS to develop modern websites and web applications.

Flowbite - Tailwind CSS components

We recommend exploring the components using the search bar navigation (cmd or ctrl + k) or by browsing the components section of the sidebar on the left side of this page.

This guide is based on the official Tailwind CSS Laravel documentation from Flowbite.


This content originally appeared on DEV Community and was authored by Zoltán Szőgyényi


Print Share Comment Cite Upload Translate Updates
APA

Zoltán Szőgyényi | Sciencx (2022-01-17T12:18:40+00:00) How to install Flowbite and Tailwind CSS with Laravel. Retrieved from https://www.scien.cx/2022/01/17/how-to-install-flowbite-and-tailwind-css-with-laravel/

MLA
" » How to install Flowbite and Tailwind CSS with Laravel." Zoltán Szőgyényi | Sciencx - Monday January 17, 2022, https://www.scien.cx/2022/01/17/how-to-install-flowbite-and-tailwind-css-with-laravel/
HARVARD
Zoltán Szőgyényi | Sciencx Monday January 17, 2022 » How to install Flowbite and Tailwind CSS with Laravel., viewed ,<https://www.scien.cx/2022/01/17/how-to-install-flowbite-and-tailwind-css-with-laravel/>
VANCOUVER
Zoltán Szőgyényi | Sciencx - » How to install Flowbite and Tailwind CSS with Laravel. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/17/how-to-install-flowbite-and-tailwind-css-with-laravel/
CHICAGO
" » How to install Flowbite and Tailwind CSS with Laravel." Zoltán Szőgyényi | Sciencx - Accessed . https://www.scien.cx/2022/01/17/how-to-install-flowbite-and-tailwind-css-with-laravel/
IEEE
" » How to install Flowbite and Tailwind CSS with Laravel." Zoltán Szőgyényi | Sciencx [Online]. Available: https://www.scien.cx/2022/01/17/how-to-install-flowbite-and-tailwind-css-with-laravel/. [Accessed: ]
rf:citation
» How to install Flowbite and Tailwind CSS with Laravel | Zoltán Szőgyényi | Sciencx | https://www.scien.cx/2022/01/17/how-to-install-flowbite-and-tailwind-css-with-laravel/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.