There is no such thing as the class "dark:". If "dark:" is a custom class, ensure that it is defined within a @layer directive

I have been using tailwindcss version 3.2.6.

I have attempted this in various ways without success. After testing it in VScode, I encountered the following error-

The `dark:` class does not exist. If `dark:` is a custom class, make sure it is defined within a `@layer` directive.

When I try to add this in global.css

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


@layer base {
    body {
        @apply max-w-2xl mx-auto px-4 bg-white text-black;
        @apply dark: bg-black dark:text-white
    }
}

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{js,ts,jsx,tsx}"
  ],
  darkMode: "class",
  theme: {
    extend: {
      fontFamily: {
        "sans": ['var(--font-rubik)']
      }
    }
  },
  plugins: [require("daisyui")],
}

app.tsx

import "@/styles/globals.css"
import type { AppProps } from "next/app";
import { ThemeProvider } from "next-themes";

import { rubik } from "@/Fonts";

export default function App({ Component, pageProps }: AppProps) {
  return (
    <ThemeProvider attribute="class">
      <main className={`${rubik.variable} font-sans`}>
        <Component {...pageProps} />
      </main>
    </ThemeProvider>
  )
}

What could be the reason behind this error?

Answer №1

If your vs code automatically adjusts the spacing when autosaving, follow these steps:

  1. Switch the language mode for that file by locating it in the Status Bar Status bar

  2. Ensure Tailwind CSS is selected as the language modeChanging the language mode

You're all set to go!

Answer №2

invalid property: dark:bg-black. The correct syntax is dark:bg-black without any spaces.

Answer №3

Follow these three simple steps

  1. If you are using VS-code, make sure to install the Tailwind CSS IntelliSense plugin. Check out this helpful screenshot with pointers

  2. Next, click on the language model tab in your status bar, which typically displays languages related to the current file (such as CSS, Javascript, Typescript, etc). You can find it at the bottom of your workspace, along with other configurable quick links like prettier.

  3. Finally, search for TailwindCSS and select it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a Background Image Using CSS3: A Step-by-Step Guide

Hey there! I'm trying to figure out how to recreate the image attached using CSS3. I've tried a few online tools for generating gradients, but no luck so far. :( I have the original image, but I really want to create the background using CSS3 in ...

Fade out a background image using jQuery

I am currently working on customizing a jQuery slider similar to NivoSlider. I want to replace the default images with my own controls. Here is what I have in HTML: <div id="slider" class="nivoSlider"> <img src="img/slider/start1.jpg" alt="" ...

Troubleshooting Next JS and Redux: Fix for getInitialProps not returning props

Looking for a skilled react developer to lend a hand. Much appreciated! I'm currently navigating the balance of using redux and NEXT JS effectively without overcomplicating the setup. OBJECTIVE: Utilize getInitialProps(for SSR) to dispatch actions ...

use jquery to increase margin on card upon collapse displaying

I'm currently using an accordion from a bootstrap 4 website. <div class="accordion" id="accordionExample"> <div class="card m-0"> <div class="card-header bg-white" id="headingOne"> <h5 class="mb-0"> <but ...

Allow the width of the container to be determined by the img element

To achieve the desired effect of making the image resolution width dictate the container width without stretching it, I am facing a challenge. Currently, when the text within a paragraph element exceeds the width of the image, the entire container expands. ...

The outer border of the Angular Material Mat Grid List is beautifully highlighted

In my project, I have a mat grid list where users can define the number of rows and columns. My goal is to display borders around each mat-grid-title cell. However, I am struggling to properly display the outermost black border for the entire mat-grid-lis ...

How can I eliminate the white bar elements from my dropdown menu? Also, seeking guidance on replacing an empty <div> tag in a boolean query

Can anyone help me understand the strange white border around my dropdown menu and guide me on how to remove it? I am currently using DropdownButton from react bootstrap. I have attempted to adjust the CSS with no success. Here is the code I tried: .Navig ...

Is it possible for a Bootstrap modal dialog to overlay another dialog window?

<button class="btn" onClick="$('#firstModal').modal('show');">Click Here</button> <!-- Modal --> <div id="firstModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden=" ...

Correct placement of elements using absolute positioning and optimized scroll functionality

I am currently working on implementing tooltips for items within a scrollable list. My goals for the tooltips are as follows: Ensure they are visible outside and not restricted by the scroll area Appear immediately after the corresponding item Be detach ...

A useful tip for jQuery users: learn how to prevent the context menu from appearing when a text box is

Is there a way to prevent the context menu from appearing in jQuery when the text box is disabled? The right-click disable functionality works well in all browsers except for Firefox. Please note that the right-click disable functionality works when the t ...

Implement a horizontal scrollbar for your table in HTML

I need to implement a horizontal scroll bar for my table. Here is the HTML code: Even though I have utilized Bootstrap, the horizontal scroll bar is not working for this particular module. It works fine in other modules. The tbody data is added after an ...

Having some trouble integrating CSS with JavaFx; encountering an error

Can anyone help me with using CSS in JavaFx? I'm encountering an error while trying to add a CSS file (style.css) to my fxml file through stylesheets. The error message I'm getting is: com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged W ...

Ways to ensure consistent element size on various devices

I am looking to maintain a fixed size for an element across different devices in reality, such as 6 x 3 cm. Currently, I have set it to 400 X 200 px and adjusted the layout accordingly (like single column display for smaller screens). While this setup wor ...

We are experiencing a high volume of requests at the moment. Please try again later. Unfortunately, Next

https://i.sstatic.net/orjxQ.pngI'm struggling with an issue in Next.js and I could really use some help. Whenever I refresh my page, I keep getting the error message "Too many requests, please try again later". The same thing happens if I click a butt ...

encountered an issue while accessing a FastAPI-based API

While developing a login feature in Next.js, I encountered an issue when making a request to an API created in FastAPI to retrieve a cookie. The problem arises during the fetch operation on the frontend specifically when setting credentials to 'includ ...

Challenges arise with CSS alignment when adding d3.js charts to a webpage

I'm puzzled by the empty space that appears between the left column (highlighted in the image) and the header. This peculiar gap only seems to occur when the middle column is filled with a chart. I've scrutinized the code using Chrome Developer t ...

Select a specific element to apply a CSS selector for a button

One of the challenges I am facing involves a webpage with multiple submit buttons. My goal is to iterate through each button and click on them one by one. While I am aware that this can be achieved using xpath like this (//button[@class='submit' ...

Step-by-step guide on repairing a countdown clock using JavaScript, HTML, and

I'm having issues with my JS on my website. I am new to this and currently in the process of setting up a website. I want to add a timer to show when the site will be active. It seems like there is an error somewhere in the JS code that I can't ...

During the prerendering process of the /write page in Next.js, a ReferenceError is thrown stating that the

Currently, I am in the process of developing an open-source blogging platform using Next.js. However, I have encountered a frustrating error while deploying the project. The issue arises when attempting to prerender the /write page, resulting in the follow ...

A transparent float is yielding unexpected outcomes

<!Doctype html> <html> <head> <meta charset="utf-8" /> <title>testing code</title> </head> <body> <div style="float: left; width: 200px; height: 150px; background-color: ...