Tailwind CSS is not outputting classes for the background

bonk

Tailwind CSS is not generating classes for the background.

When I tried to create a simple class like bg-black, it didn't add it to the output.css file. However, when I would temporarily put something like a grid or flex in there, it would add the class to the output. Is it syntax, the config file, or something else entirely? Let me know if you need more code, and thanks in advance!

CONFIG (tailwind.config.js):

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./index.html"],
  theme: {
    colors: {
      transparent: "transparent",
      current: "currentColor",

      backgroundpink: {
        DEFAULT: "#faeaf5",
      },
      primarypink: {
        DEFAULT: "#eaa4b1",
      },
      vanilla: {
        DEFAULT: "#f7e6de",
      },
      accentorange: {
        DEFAULT: "#eabaa4",
      }

    },
    extend: {},
  },
  plugins: [],
}

HTML (index.html):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body class="bg-black">
    
</body>
</html>
Wongjn

The color black does not exist in the final resolved Tailwind configuration because you have completely overridden the default Tailwind colors by specifying theme.colors object.

If you did indeed want to completely override the default Tailwind colors but still want black as a color, add it to theme.colors.black:

/** @type {import('tailwindcss').Config} */
module.exports = {
  // …
  theme: {
    colors: {
      // …
      black: '#000',
    },
    extend: {},
  },
  // …
}

Otherwise, if you wanted to keep the default Tailwind colors but define yours in addition:

/** @type {import('tailwindcss').Config} */
module.exports = {
  // …
  theme: {
    extend: {
      colors: {
        // `transparent` and `current` aren't strictly needed here
        // since they are in the default Tailwind color palette.
        // transparent: "transparent",
        // current: "currentColor",
        backgroundpink: {
          DEFAULT: "#faeaf5",
        },
        primarypink: {
          DEFAULT: "#eaa4b1",
        },
        vanilla: {
          DEFAULT: "#f7e6de",
        },
        accentorange: {
          DEFAULT: "#eabaa4",
        }
      },
    },
  },
  // …
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Tailwind preset is outputting css, but not showing styles on the webpage

make gradient background with tailwind css

Tailwind css background gradient not applying

Tailwind CSS not loading custom classes on React app

Add spacing in between items with css tailwind classes

Using Tailwind opacity classes with CSS variables

How in Tailwind CSS to use classes with arbitrary values

Tailwind css purge removes all dark classes

Color classes of Tailwind CSS not working when appended

Tailwind css classes not showing in Storybook build

Tailwind css 3.0.5 classes is not working with react

Tailwind CSS background Image not Working with @apply

tailwind css config file background image issue

Does Tailwind CSS remove unused custom CSS classes in production?

Unable to Apply Tailwind CSS Classes in React Component (TypeScript)

Laravel + Tailwind CSS - Classes not available due to being in Variables

Tailwind CSS convert more of these inline styles to utility classes

React and Tailwind CSS: dynamically generated classes are not being applied

Tailwind CSS classes show up in the DOM, but the styles are not being applied

Is there a way to chain multiple tailwind css classes on a single hover instance?

background-image in css style doesn't work in laravel with tailwind

How to fit image as background cover in a div in tailwind css

How do I transition background color with Tailwind CSS in React?

Tailwind CSS custom color applying to text but not background in ReactJS

Background property is not being applied even using tailwind and normal css

Disable prettier for Tailwind classes

Aliases for tailwind classes?

header alignment with tailwind classes

Creating Classes and Outputting