How to Integrate TailwindCSS with daisyui in Shopify: Step-by-Step Guide

.shopifyignore
in the root folder of your Shopify project and add the following content:node_modules
package.json
package-lock.json
.gitignore
file (if you don't already have one) and add node_modules
:node_modules
package.json
:npm init -y
npm install tailwindcss @tailwindcss/vite
assets
directory, create a file named tailwind.input.css
and add the following line:@import "tailwindcss";
concurrently
npm package as a development dependency. This package helps run multiple commands simultaneously:npm install concurrently --save-dev
package.json
file and add the following script inside the "scripts"
section:"dev": "concurrently \"shopify theme dev -e development\" \"npx @tailwindcss/cli -i ./assets/tailwind.input.css -o ./assets/tailwind.output.css --watch\""
npm run dev
assets/tailwind.output.css
and notice that TailwindCSS has purged unused styles and kept only the required ones. theme.liquid
file and before the closing </head>
tag, include the generated CSS
file:<head>
<!-- Other head elements -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{ 'tailwind.output.css' | asset_url | stylesheet_tag: preload: true, media: 'all' }}
</head>
Note: If you don’t add
<meta name="viewport" content="width=device-width, initial-scale=1.0">
in thetheme.liquid
thetailwindcss
media queries WILL NOT WORK.