Install Tailwind CSS with npm

Ahmad Awais
Follow on Twitter @MrAhmadAwais
Install Tailwind CSS with npm.
For most of your projects all you need to install Tailwind CSS is runn the following command.
npm install tailwindcss@latest postcss@latest autoprefixer@latest
This will install the latest tailwindcss
, postcss
, and autoprefixer
.
Create Tailwind CSS configuration file
Now the next logical step is to create a configuration file for Tailwind CSS i.e. tailwind.config.js
. To do that you can run this handy command.
npx tailwindcss init
This command will create a minimal tailwind.config.js
file at the root of your project, that looks like this:
// tailwind.config.jsmodule.exports = { purge: [], darkMode: false, // or 'media' or 'class' theme: { extend: {}, }, variants: {}, plugins: [],}
That's about it. Have fun!

Ahmad Awais
Follow on Twitter @MrAhmadAwais