The `border-border` class cannot be found. In the case that `border-border` is a personalized class, ensure that it is declared within a `@layer` directive

The border-borderclass is not recognized. Ifborder-border

is a custom class, ensure it is defined within a
@layer directive.

globals.css

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


 
@layer base {
  * {
    @apply border-border; //error
  }
  body {
    @apply bg-background text-foreground;
  }
}

I am puzzled by how this issue arose. It occurred in a React - Next app using Tailwind CSS and TypeScript, possibly related to the configuration in tailwind.config or globals.css files.

Answer №1

In the event that someone experiences this issue, it came to my attention that I had both a tailwind.config.js and tailwind.config.ts files in the top-level directory of my repository (I had forgotten to remove the tailwind.config.js).

Removing the unnecessary tailwind.config.js resolved the issue.

I hope this information proves helpful!

Answer №2

In your tailwind.config.js file, make sure to include a prefix for classes that you define in your .css file. For instance, if you have a class named border-border and your prefix is 'tw-', then modify it to tw-border-border.

I encountered a similar problem while working with plate editor.

Answer №3

According to the error message, in order to use @apply for a class name, Tailwind must recognize the class either through a Tailwind plugin or in a @layer base/components/utilities.

The class name border-border is not predefined in Tailwind, so you will need to define it in order to use @apply.

You can define it in a Tailwind plugin like this:

module.exports = {
  // …
  plugins: [
    plugin(function({ addUtilities }) {
      addUtilities({
        '.border-border': {
          // Your styles here
        },
      })
    })
  ]
}

Alternatively, you could use border as a value for borderWidth to generate a border-border class using the core Tailwind borderWidth plugin:

module.exports = {
  // …
  theme: {
    extend: {
      borderWidth: {
        border: 'Your value here',
      },
    },
  },
}

Another option is to define it in your CSS within a @layer:

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

@layer base {
  .border-border {
    /* Your styles here */
  }

  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
  }
}

Answer №4

Delete the tailwind.config.js file to only keep the tailwind.config.ts file.

Answer №5

The issue primarily arises due to the TypeScript extension tailwind.config.ts. To resolve this issue, you need to maintain the SADHCDN UI question:

Where is your tailwind.config.js located?
, ensuring it has a .js extension. If you already have a tailwind.config.ts file in your Next.js project, simply delete it and retain the tailwind.config.js file generated by SADHCDN UI. This should clarify things and assist you moving forward.

Answer №6

Encountering a comparable issue, I discovered that certain styles were deleted from tailwind.config.js during the installation of tremor. It could be beneficial to review your version control and ensure nothing has been removed from tailwind.config.js.

Answer №7

I encountered a similar issue due to using custom CSS variables with Hex colors in my setup, which were referenced in tailwind.config.js.

❌ Incorrect Tailwind 2 syntax

:root{
  --color-primary: #9D4E48;
}
colors: {
  primary: 'var(--color-primary)',
}

→ The solution was transitioning from Tailwind 2 syntax to Tailwind 3 syntax:

✅ Correct Tailwind 3 syntax

:root{
  --color-primary: 6deg 37.0% 38.6%; /* equivalent to #9D4E48 */
}
colors: {
  primary: 'hsl(var(--color-primary) / <alpha-value>)', // #9D4E48
}

Refer to the documentation on using CSS variables in TailwindCSS for more information.

If you prefer an easier way, you can rely on ChatGPT/Copilot to assist in converting your colors.

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

How can I prevent or override the text being pushed to the right by CSS::before?

Using the css property ::before, I am attempting to insert a tag before a paragraph. While I am able to display the tag correctly, it is causing the text within the paragraph to be shifted to the right. Ideally, I would like the tag to appear in the top-le ...

Issue with TinyMCE Editor: Inoperative

<script type="text/javascript" src="<your installation path>/tinymce/tinymce.min.js"></script> <script type="text/javascript"> tinymce.init({ selector: "textarea", theme: "modern", plugins: [ "advlist autolink li ...

Using Bootstrap 4: How to maximize the width of a span element placed near a label

I need to adjust the width of a span next to its label in my project. My goal is to show multiple groups {label / data} on the same line. To achieve this, I divided the row into 4 columns and tried to set a specific width for a span. However, no matter wh ...

Styles coded in CSS are not reflecting on the displayed webpage, despite being visible in the Integrated

Custom Styling for ASP Membership Login in Visual Studio 2008 I am experimenting with customizing the ASP:Login control by converting it into a template. Here is the updated markup: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx. ...

The rating and comment section is failing to adapt to smaller screens, creating a terrible user experience

I am a beginner with Sass and CSS. I wanted to create a rating and comment section which looks fine on a laptop screen, but appears off on smaller screens. It seems like the layout might be incorrect or maybe I didn't follow grid layout guidelines pro ...

What is the best way to conceal the main list but still show the nested list within?

I'm looking for a way to conceal the main parent of a sub-list while still displaying the nested list. Furthermore, I need to ensure that the parent element doesn't occupy any space on the page when hidden. HTML <ul> <li class="par ...

Testing NextJS App Router API routes with Jest: A comprehensive guide

Looking to test a basic API route: File ./src/app/api/name import { NextResponse } from 'next/server'; export async function GET() { const name = process.env.NAME; return NextResponse.json({ name, }); } Attempting to test ...

Linking Background Images in HTML

Is there anyone who can provide assistance with this question? I am looking for a solution where I can have a link with a background image, placed in a row within a table. Your help would be greatly appreciated. Thank you ...

Is there a way to emphasize text within a string of object array items?

I am currently utilizing the data provided below to pass as props in React. The functionality is working smoothly, but I have a specific requirement to only emphasize the words "target audience" within the text property. Is there a feasible way to achieve ...

Trouble Scrolling Webpage Vertically on Screens Exceeding 768px Width

I've been searching high and low for an answer that seems to be right in front of me, but I just can't see it. The issue is quite simple: the page refuses to scroll vertically on screens wider than 768px: Whenever the screen size exceeds 768px, ...

Tips for formatting dates in react-calendar?

After reviewing the document, I noticed the formatLongDate function but it doesn't seem to be formatting the date as expected. I am looking to display the date in the format YYYY-MMM-dd, however, the calendar is displaying it like this: Wed Apr 07 20 ...

Using shadow effects on the <Grid> component with Material UI

Is there a way to implement the box-shadow property on a <Grid> component in Material UI? I've gone through the official documentation regarding Shadows - Material UI, but I'm struggling to grasp how it can be applied to a <Grid>. De ...

"Is there a way to align a span element on the same line as an h

I'm attempting to align a text-number (span) next to an entry-title (h2) on the same line, with the entry-meta block on the following line, including having the reading time float left. I could use some help with my CSS implementation. Thank you. Ex ...

Numerous sections with tabs on the webpage

I am in need of incorporating multiple tabbed sections on a single page, but unfortunately they are currently interconnected. When one tab is clicked, it impacts the others. To see this issue in action, you can visit: https://jsfiddle.net/pxpsvoc6/ This ...

How to Style an Element Based on Fragment Identifier in Href Attribute Using CSS

I've implemented the tabview feature from the YUI3 library. This is how the markup code appears: <div id="demo" class="yui3-tabview-content"> <ul class="yui3-tabview-list"> <li class="yui3-tab yui3-widget yui3-tab-selected"> ...

Hermes js engine encounters a TypeError when attempting to access the property '__expo_module_name__' of an undefined value

After updating my expo and react native app to the latest version, I encountered a problem that I couldn't find a solution for despite searching on Google. Link to image ...

Relocate a table beside an image

Check out the layout of my webpage: ------------- ------------- Image here ------------- ------------- Table1 here Table2 here Table3 here My goal is to redesign it to look like this: ------------- ------------- Image here Table1 here - ...

Having trouble retrieving items from local storage in NextJS?

After logging in to my NextJS application, I store some user data in local storage. I'm attempting to create a small component that always shows the user's name. The problem I'm encountering is that sometimes it displays correctly and other ...

What is the process for generating an array of objects using two separate arrays?

Is there a way to efficiently merge two arrays of varying lengths, with the number of items in each array being dynamically determined? I want to combine these arrays to create finalArray as the output. How can this be achieved? My goal is to append each ...

Is it necessary for React to pass onClick as props to sub components?

Attempting to activate an onClick function within a sub-component by including the onClick in the parent component did not yield the desired outcome. // parent component class MainForm extends Component { // code here handleClick = () => { con ...