Skip to content

Tailwind CSS


VS Code

Tailwind CSS IntelliSense


A Prettier plugin for Tailwind CSS that automatically sorts classes based on our recommended class order:



[](Gimli Chrome browser extension) - Starter Blog Template (Next,js + Tailwind)

Copy Tailwind CSS code from any website

Installation for Wordpress and Shopify

For Next.js see:

These setup instructions will install the Tailwind and PostCSS config files in the css folder. The final output file tailwind.css is saved in the top level. The package.json is also in the top level folder, so npm run dev can be run from there.

npm init -y
npm install -D tailwindcss postcss postcss-cli cssnano postcss-preset-env postcss-nesting

Make sure to add /node_modules to .gitignore.

Install in /css and generate config files:

mkdir css && cd css && npx tailwindcss init -p

Configure Tailwind to remove unused styles in production.

Example tailwind.config.js for WordPress:

module.exports = {
  content: [
    // "./**/*.{php,js,html}",

Example tailwind.config.js for Shopify content:

content: ["./layout/theme.liquid", "./templates/*.liquid", "./assets/*.js"],

Add Tailwind to the main css file, /css/tailwind.css.

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

Configure /css/postcss.config.js.

This config uses postcss-preset-env which enables use of custom media queries, amongst other things. It includes autoprefixer which is why it is turned off in cssnano. Tailwind recommends letting tailwindcss/nesting handle the nesting instead of postcss-preset-env.

module.exports = {
  plugins: {
    'tailwindcss/nesting': 'postcss-nesting',
    tailwindcss: { config: './css/tailwind.config.js' },
    'postcss-preset-env': {
      features: { 'nesting-rules': false },
    cssnano: {
      preset: "default",
      autoprefixer: { add: false },

Add scripts to package.json for WordPress:

    "dev": "postcss css/tailwind.css --output tailwind.css --watch",
    "build": "postcss css/tailwind.css --output tailwind.css"

Add scripts to package.json for Shopify:

    "dev": "postcss css/tailwind.css --output assets/tailwind.css --watch",
    "build": "postcss css/tailwind.css --output assets/tailwind.css"

Start Tailwind for development.

npm run dev

Typography / Prose plugin<br> Beautiful typographic defaults for HTML you don't control. Provides a set of prose classes.

npm install -D @tailwindcss/typography

Forms Plugin

Wordpress theme setup

Delete everything out of style.css except theme header info.

In functions.php comment out style.css and add in tailwind.css:

wp_enqueue_style(projectX-style',  get_template_directory_uri() . '/tailwind.css', array(), filemtime(get_stylesheet_directory() . '/tailwind.css'));

Or insert tailwind.css directly into the header. So, remove css from functions.php as per above. Then add to header.php.

<style media="screen">
  <?php include dirname(__FILE__).'/tailwind.css'; ?>

Shopify theme setup

Add to theme.liquid after the base.css line.

{{ 'tailwind.css' | asset_url | stylesheet_tag }}


Add globals in styles/globals.css:

@layer base {
  p {
    @apply pt-4;

Customise the theme

Add custom font.

  theme: {
    fontFamily: {
      sans: ["aktiv-grotesk", "sans-serif"],

Extend the theme:

  theme: {
    extend: {
      fontSize: {
        md: "1.0625rem",
      fontFamily: {
        usual: ["usual", "sans-serif"],
      colors: {
        'blk': '#243c5a',


Can be used in the globals stylesheet like so:

@media screen(md) {


With Next.js

To conditionally show a class would be something like this:

function Notification() {
  const [isNotification, setIsNotification] = useState(false);

  return (
    <div className={` ${isNotification ? "animate-ping" : null} h-2 w-2 m-5 bg-sky-400 rounded-full`}></div>