When the tailwind utilities are implemented, they do not appear on the screen

Recently, I embarked on a project using Tailwindcss/Next.js and encountered an issue when trying to apply a box-like shadow to a button with a new utility in pure CSS. Despite my efforts, the changes don't seem to take effect. Can you spot what I might have missed?

index.jsx:

...
<button className="text-xl font-bold italic cursor-pointer border-textwhite
 border-2 w-52 bg-primary h-10 uppercase box-shadow-black">
Buy Now
</button>
...

index.css:

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

@layer utilities {
  .box-shadow-black {
    box-shadow: 0.125rem 0.125rem 0 0px #000;
  }
}

Answer №1

Functioning fine, but encountering minor issues: border-textwhite instead of text-red-500, and the clash between border and border-2. I opted for border-2 alongside adding a touch more shadow 0.2rem for a better visual effect! Also, don't forget the steps to set up tailwindcss with next.js. Best of luck! ;-)

index.js

import Head from "next/head";

export default function Home() {
  return (
    <div>
      <Head>
        <title>Create Next App</title>
        <meta name="description" content="Generated by create next app" />
        <link rel="icon" href="/favicon.ico" />
      </Head>

      <div className="flex items-center justify-center h-screen flex-col gap-5">
        <button className="text-xl font-bold italic cursor-pointer text-red-500 border-2 w-52 bg-primary h-10 uppercase box-shadow-black">
          Buy Now
        </button>
      </div>
    </div>
  );
}

globals.css

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


@layer utilities {
  .box-shadow-black {
    box-shadow: 0.2rem 0.2rem 0.2rem 0px black;
  }
}

output :

https://i.stack.imgur.com/xJb9u.png

"next": "12.0.7","react": "17.0.2","tailwindcss": "^3.0.5"

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

Enabled the swcMinify setting to true in Next.js version 12

Recently, I made the decision to remove my babelrc file in favor of the new rust compiler, which is being endorsed by Vercel. However, this change caused my build process to break down. The only content within my babelrc was: { "presets": [&quo ...

Encountering ERR_TOO_MANY_REDIRECTS error while deploying my Next.js app on Cloudways hosting platform

My app's page is displaying ERR_TOO_MANY_REDIRECTS This issue only occurs when the site is hosted on cloudways, as it works fine locally. I have tried various solutions but have been unable to identify the cause of the problem. The URL for the sit ...

Issue with 'backface-visibility' CSS3 property not functioning on any versions of Internet Explorer

I'm looking to implement a specific animation in Internet Explorer. The goal is to rotate an image like a coin, displaying a different image on the other side. I suspect that the issue lies with Backface-visibility in IE, but I'm not entirely sur ...

Should you construct a fresh element using JavaScript, or opt to reveal a concealed one using CSS?

What are the benefits of using the following approach: var target = document.getElementById( "target" ); var newElement = document.createElement( "div" ); $( target ).after( newElement ); compared to just hiding the newElement div with CSS and showing ...

HTML header with zero margin

Hi there! I am currently learning the basics of HTML and CSS. I have a question regarding creating a header with no margins on the edges. Any advice would be greatly appreciated as I haven't been able to find a clear solution. Below is my code snippet ...

Achieving Perfect Alignment for Absolutely Positioned Divs in

I'm currently facing an issue where the image I'm trying to center horizontally also moves the parent div downward when I try to vertically center it using top-margin. This is not the desired outcome. If you'd like to see what I mean, I&apo ...

Tips for expanding the width of an image when employing position:relative

Below is the code snippet: <table border="1" cellpadding="2" cellspacing="2" height="250"> <tbody> <tr> <td> <div style="background: url('path to image'); width: 300px; height: 250px; position: ...

The most effective method for positioning a child element to the left and top using Flexbox grid

I am currently working on visualizing queues and processes within a system. Each process is associated with a specific queue from which it retrieves data. I aim to create a layout similar to the following: https://i.stack.imgur.com/BXyts.png However, I a ...

What are some strategies for disregarding the effects of the !important rule

After incorporating some HTML and CSS styling into a third-party site, I encountered an issue where their styling was conflicting with mine, specifically due to certain !important declarations. I want to avoid this conflict without resorting to using !impo ...

There seems to be an issue with the hydration process in NextJS when using styled-components with a component

Currently, I am in the process of developing a component library for a brand new nextJS application. This nextJS application utilizes the "app router" feature. Everything functions perfectly when I directly integrate styled-components into the nextJS code ...

What is the solution for correcting the error message "Prop `className` doesn't match. Server: 'MuiFormLabel-root-75....' "?

Currently using NextJS, I attempted to incorporate "@material-ui/core" into my project. Upon trying to utilize the TextField, I encountered the following error: index.js:2178 Warning: Prop className did not match. Server: "MuiFormLabel-root-75 MuiInpu ...

Having trouble with the JavaScript DOM rewrite for aligning text?

function modifyTextAlignment(){ document.getElementById("th1").style.textAlign = "right"; } #th1{ text-align:left; } <table> <tr><center><th colspan="2" id="th1">List of Important Emergency Contacts</th><center></tr& ...

During the initial cycle, the CSS keyframes animation may experience glitches, but it will run smoothly in subsequent cycles

Seeking advice on troubleshooting a CSS keyframes animation issue. I have created an animation with 5 frames where the background image fades and transitions to the next image smoothly in all cycles, except for the first cycle where it glitches before each ...

What to do when encountering the error "Uncaught (in promise) SyntaxError: Unexpected end of JSON input"?

While signing in to my website from localhost is successful, I encounter an issue when trying to do the same from my production build. The login attempt from the prod build (hosted on Vercel) does not post to , but instead goes to . I am perplexed by the a ...

Create stunning HTML emails by incorporating a transparent background color behind images and text

Is there a way to add text on a transparent background layer placed over an image without using the background-image property? In my case, I am working on an HTML Emailer and must utilize the img tag instead. Any suggestions on how to achieve this? < ...

Having issues with my CodePen React code and its ability to display my gradient background

I will provide detailed descriptions to help explain my issue. Link to CodePen: https://codepen.io/Yosharu/pen/morErw The problem I am facing is that my background (and some other CSS elements) are not loading properly in my code, resulting in a white bac ...

Implementing Default Language in Next.js 14 for Static Export without URL Prefix: A Step-by-Step Guide

Currently, I am in the process of developing a website using Next.js 14, with the intention of exporting it as a static site for distribution through a CDN (Cloudflare Pages). The website I am working on requires support for internationalization (i18n) to ...

I'm currently experiencing a challenge with a project I'm tackling that specifically deals with chart.js

In my recent coding project, I created a script to gather user input and then present it in various chart formats. However, upon executing the code, the selected chart fails to display after inputting values and clicking on the "generate chart" button. Her ...

Which Javascript/Css/HTML frameworks and libraries would you suggest using together for optimal development?

Interested in revamping my web development process with cutting-edge libraries, but struggling to navigate the vast array of tools available. The challenge lies in finding a harmonious blend of various technologies that complement each other seamlessly. I& ...

Having trouble with the functionality of Bootstrap's nav-tabs 'show' feature?

I'm having some issues with adding a search box to my glossary. The glossary is created using nested unordered lists (ul) within another ul that has classes of "nav-tabs" and "bootstrap". In the JavaScript code, I am using the following snippet: $j(& ...