question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There is a way to use TailwindCSS on this boilerplate ?

See original GitHub issue

Description

I am struggling to install/use TailwindCSS I am using v1.2.4 updated to React 18.1.0, react-router 6.3.0 react-script 5.0.1 (everything works fine).

Steps to reproduce

> yarn create react-app --template cra-template-rb my-app > cd my app > yarn -D tailwindcss postcss autoprefixer > yarn tailwindcss init -p

Add the following code to tailwind.config.js

content: [
    "./src/**/*.{js,jsx,ts,tsx}",
  ],

Add the following declaration to src/styles/global-style.ts

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

Expected behavior

The css is not applied, css class are in the dom, but the tailwind’s css isn’t load.

Thank you for your help.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
lyndon-baylincommented, Jul 12, 2022

Description

I am struggling to install/use TailwindCSS I am using v1.2.4 updated to React 18.1.0, react-router 6.3.0 react-script 5.0.1 (everything works fine).

Steps to reproduce

> yarn create react-app --template cra-template-rb my-app > cd my app > yarn -D tailwindcss postcss autoprefixer > yarn tailwindcss init -p

Add the following code to tailwind.config.js

content: [
    "./src/**/*.{js,jsx,ts,tsx}",
  ],

Add the following declaration to src/styles/global-style.ts

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

Expected behavior

The css is not applied, css class are in the dom, but the tailwind’s css isn’t load.

Thank you for your help.

I think you forgot to include the index.html in the public folder into the content property of your tailwind.config.js that is why your TailwindCSS did not work.

Try to do it like this.

  content: ['./public/index.html', './src/**/*.{js,jsx,ts,tsx,html}'],

This is my tailwind.config.js in my personal project that I currently working on using the latest release of the boilerplate at the time of this response. I have no issues of tailwindcss in my end. Hope this helps.

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./public/index.html', './src/**/*.{js,jsx,ts,tsx,html}'],
  theme: {
    screens: {
      // Small devices (landscape phones, 576px and up)
      sm: '576px',
      // Medium devices (tablets, 768px and up)
      md: '768px',
      // Large devices (desktops, 992px and up)
      lg: '992px',
      // X-Large devices (large desktops, 1200px and up)
      xl: '1200px',
      // XX-Large devices (larger desktops, 1400px and up)
      xxl: '1400px',
    },
    fontFamily: {
      sans: [
        'Inter',
        '-apple-system',
        'BlinkMacSystemFont',
        'Helvetica Neue',
        'Helvetica',
        'sans-serif',
      ],
    },
    extend: {},
  },
  plugins: [require('@tailwindcss/forms')],
};

Also this my devDependencies in package.json

"devDependencies": {
    "@tailwindcss/forms": "0.5.2",
    "autoprefixer": "10.4.7",
    "postcss": "8.4.14",
    "prettier-plugin-tailwindcss": "0.1.11",
    "tailwindcss": "3.1.4"
  }
1reaction
Silthuscommented, Jun 25, 2022

I have the same issue and put together an example branch: https://github.com/Silthus/betonquest-editor/tree/issues/cra-boilerplate-tailwindcss

Read more comments on GitHub >

github_iconTop Results From Across the Web

A bare-bones Tailwind CSS boilerplate - GitHub
It creates a simple HTML + CSS template with Tailwind CSS support, served by Parcel and using PurgeCSS in production builds.
Read more >
Tailwind CSS + WordPress Theme & Block Type Boilerplate
Here's how I'm using Tailwind CSS in WordPress themes and blocks. My premium courses and coupons: https://learnwebcode.com/courses/GitHub ...
Read more >
Installation - Tailwind CSS
The simplest and fastest way to get up and running with Tailwind CSS from scratch is with the Tailwind CLI tool.
Read more >
Tailwind CSS - Rapidly build modern websites without ever ...
Utility classes help you work within the constraints of a system instead of littering your stylesheets with arbitrary values. They make it easy...
Read more >
Install Tailwind CSS with Create React App
Create your project · Install Tailwind CSS · Configure your template paths · Add the Tailwind directives to your CSS · Start your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found