Enhancing the appearance of child elements using CSS modules in Next.js

My Countdown component implementation includes:

import styles from "./Countdown.module.scss";
import React from "react";
import useTimer from "hooks/useTimer";
import cn from "classnames";

function Countdown({ date,className="" }) {
  const { days, hours, minutes, seconds } = useTimer(date);
  return (
    <div className={cn(styles.countdown,className)}>
      <div className={styles.box}>
        <p className={styles.number}>{days}</p>
        <p className={styles.type}>Days</p>
      </div>
      <div className={styles.seperator}>:</div>
      <div className={styles.box}>
        <p className={styles.number}>{hours}</p>
        <p className={styles.type}>Hours</p>
      </div>
      <div className={styles.seperator}>:</div>
      <div className={styles.box}>
        <p className={styles.number}>{minutes}</p>
        <p className={styles.type}>Minutes</p>
      </div>
    </div>
  );
}

export default Countdown;

The structure of my home page is as follows:

import styles from "../styles/Home.module.scss";
import Countdown from "components/ui/Countdown";
export default function Home() {
  return (
    <div className={styles.container}>
      {/* top summary */}
      <div className={styles.summary}>
          <Countdown date={"10/06/2021"} className={style.homeCountdown} />
      </div>
    </div>
  );
}

I am seeking a way to apply specific styling to the hours paragraph tag in the Countdown component when it is displayed on the home page. Is there any approach to achieve this without passing an additional prop?

Answer №1

Consider incorporating a "settings" prop within your component for an alternative approach.

<Timer deadline={"10/06/2021"} style={style.countdown} settings={{displayLabels: false}}/>

Then, adjust these settings in the component's functionality.

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

When navigating to a new page in a PDF using react-pdf, the document automatically scrolls to the top

I have integrated react-pdf (github link) into my React application to display PDF files. Below is the code snippet: import { useColor } from '@/hooks'; import { ArrowLeftIcon, ArrowRightIcon } from '@chakra-ui/icons'; import { HStack, ...

Display a block by using the focus() method

My objective is : To display a popin when the user clicks on a button To hide the popin when the user clicks elsewhere I previously implemented this solution successfully: Use jQuery to hide a DIV when the user clicks outside of it However, I wanted to ...

What is the default way to toggle content in rows using Material UI?

Currently, I am utilizing Muitables and have a query regarding how to set the expanded rows to be displayed by default, similar to the illustration below: Upon initial page load, it is preferred for the content in that row to automatically expand (arrow d ...

Position filter forms on the left side to align with bootstrap cards

I'm having trouble aligning the cards using Bootstrap's row and col- classes. The first three are behaving as expected, but the fourth one isn't cooperating. Any idea why this might be happening and any solutions you can suggest? View the i ...

Warning of superfluous escape character when executing 'npm start' on a React application

I have encountered a warning while running my React app using npm start. The warning appears in the terminal and reads as follows: Line 24: Unnecessary escape character: \[no-useless-escape The warning is related to the following code snippet: va ...

What are the benefits of using "this.props.dispatch" instead of directly using "store.dispatch" in Redux?

Is there a downside to using store.dispatch directly? I find it more convenient to call (as it's accessible to all child components) and in my experimentation, I haven't noticed any difference yet. Appreciate your insights! ...

Enhancing State in React Component through Prop Update

I am aiming to achieve the functionality of clicking a button in a child component and having that component removed. I am new to React and currently in my app.js file, I have a component with a prop like this: <IntroSteps isHidden={false} /> Inside ...

An unexpected error occurred in NEXT.js: Minified React error #418; #423

After inputting these codes in the page.tsx file, everything seems fine in dev mode. However, once I build the page, the {tag.name} does not display and two errors are thrown: Uncaught Error: Minified React error #418; and Uncaught Error: Minified React er ...

Resizing images in different web browsers: Chrome, IE, and Safari

I'm currently in the process of building a website that utilizes the jquery tabs api. Each tab on the site contains an image that I would like to resize dynamically as the browser window size changes. Here is an example of one of the tabs: <li st ...

Building secure routes in React with NextJS

Objective : My goal is to automatically redirect a user who is logged in back to the home page if they try to manually access the /auth/signin route. Signin page/component : const Signin = ({ currentUser }) => { const [email, setEmail] = useState ...

The sticky table header is being covered by a disabled HTML button, while the active buttons are not visible

I'm currently working on a website using Bootstrap 5 as my framework. The issue I'm facing is that when scrolling down the page and keeping the table header stuck to the top, the disabled button ends up showing over the header. I attempted to us ...

How can we display an absolutely positioned div when hovering over a card with the help of Tailwind CSS?

I am currently working on a Next.js application with Tailwind CSS. I would like to implement a feature where additional information is displayed when hovering over a product card, similar to the functionality seen on wildberries.ru. I have tried using &apo ...

Using Jinja2/Python, is it possible to alter the parent's style depending on the child's value?

Initially, I found that the :has() combinator accomplishes my desired outcome. In my HTML, I have a table structured like this: <table class="table"> {% for dict_item in data | sort(attribute='name') %} <tr class=" ...

Navigating routes with role-based permissions in Next.js using React

Looking to implement role-based access control in a React project using Next.js for authentication. I have two roles - admin and user - stored in the session after login. The _app.jsx file within the pages folder sets up the app with various dependencies a ...

Inconsistencies with Colorbox behavior in an external HTML document

Encountering a strange issue with colorbox while attempting to display a "div" element from another HTML file. The code functions perfectly, except for the final "div" in the external file. The structure of my external file is as follows; div1 img par ...

The website shifts as you navigate to a new page

Could use some insight on an issue with my website . Whenever I navigate to a different page, like the "Rules" page from the main site, the container seems to shift down slightly. Any ideas on what could be causing this? I've been struggling to pinpoi ...

Converting a CSS Submenu from Horizontal to Vertical Orientation

Below is the current code snippet for my menu navigation bar: To access my live blog, please click on this link: www.4time2fun.com <div id="topmenu"> <div id="navigation"> <ul class="categories"> <li class="articles"> <a href ...

Error 404 when trying to access a Netlify page after clicking a button

Hello everyone, I'm reaching out because I am a newcomer here and have encountered an issue that I need help resolving. My app is deployed on netlify and functions properly when tested locally; however, upon testing it on netlify with a function, I re ...

The initial processing step for the export namespace is to utilize the `@babel/plugin-proposal-export-namespace-from` plugin. Previous attempts to resolve this issue have been

I encountered a problem with my application and found two related questions on the same topic. However, due to a lack of reputation, I am unable to comment or ask questions there. That's why I'm reaching out here... Recently, I integrated Redux ...

Create a specific definition for a packaged item with limited access

As I worked with a package that lacked types, I took the initiative to create a type definition for it. The specific package in question is react-date-range. In order to accommodate this new type definition, I established a directory where it could be loca ...