What is the proper class name for the element to function correctly?

Here is a snippet of the Next.js code I am working on:

import ReactMarkdown from 'react-markdown'
import gfm from 'remark-gfm'
import styles from './content.module.css'
return (
  <article className={styles.markdownbody}>  // here
    <ReactMarkdown remarkPlugins={[gfm]}>
    {props.markdown}
    </ReactMarkdown>
  </article>
)

Below is a portion of my CSS stylesheet:

.markdown-body {
  color-scheme: dark;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  margin: 0;
  color: #e6edf3;
  background-color: #0d1117;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.5;
  word-wrap: break-word;
}

I have tried using className as styles.markdownbody, styles.markdown_body, styles.markdownBody, styles.markdown-body but it's not working. Any suggestions on what it should be?

The different attempts I've made with classname are not producing the desired outcome.

Answer №1

When utilizing CSS modules, it's important to note that class names are not automatically processed. This means you must specifically reference them like so:

styles['markdown-body']

(Inspecting the styles variable will confirm this)

According to the documentation:

Naming

CamelCase naming is recommended for local class names in CSS modules, although it is not mandatory.

This recommendation stems from the fact that using kebab-case may lead to unexpected behavior when attempting to access a style with dot notation. While you can still use bracket notation to work around kebab-case (e.g. style['class-name']), accessing it as style.className is cleaner and more intuitive.

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

What is the best method for ensuring three inside divs have equal heights?

I am working with a container div#content that holds three inner divs. I want to ensure that all three divs have the same height, but also expand based on their content. Here is an example of what I have tried: <!doctype html public "-//w3c//dtd html 4 ...

Difficulty encountered in setting the width of a sticky bottom element to be located at the bottom of the page with Tailwind

Fiddle: https://play.tailwindcss.com/pvT1jW8zZd Here is the code snippet I am working with: Here is how it currently appears: https://i.sstatic.net/2SRny.png <div class="bg-yellow-300"> <div class="p-16 m-5 text-xl bg-gray-500 ...

How to change the background color of a slider using jQuery

As a newcomer to web programming, I am currently working on incorporating a slider into my website using jQuery. My goal is to change the background color of the slider to red when the value is less than 5 and green when it exceeds 5. Can this be achieved ...

Removing the Arrow on a Number Input Field Using Tailwind CSS

Is there a way to remove the default increment/decrement arrows that come with an input of type number using Tailwind CSS? I've searched for a solution but haven't found one yet. input type="number" placeholder="Phone number" className="border ...

Is it possible for the Nextjs application to run in the background using the command line?

Looking for a way to run my Nextjs code in the background on Linux: Running command: npm run dev // Result is working fine at http://localhost:3000 However, running in the background with pm2 start npm --name "nextjs-13" -- start // Application does not w ...

Move the image inside the box without directly following the mouse cursor, but at a slightly faster pace

I am facing an issue with a Vue component that allows me to zoom in on an image and move it around the container. The problem is, when the image is zoomed in, it moves faster than the mouse due to using the scale transform. Additionally, I noticed that cl ...

Why isn't the Angular directive resolving the dynamic button text variable?

Trying to implement an iPhone-style Toggle Button using CSS in Angular. The issue I am facing is that the dynamic button text variable "{{v1['btn2']}}" is not being evaluated properly the first time, although it works fine with static text. URL ...

Have you ever wondered how the automatic video play on scroll feature works on Tiktok.com and YouTube shorts when using a mobile device?

My goal with React JS is to develop a website similar to Tiktok, where the video below will automatically play with sound as the user scrolls down. I attempted to set this up using window.addEventListener("scroll",...), but after looking into it further, ...

How can one retrieve the value of AngularJS {{curly-brace-value}} using jQuery?

Although I may not be well-versed in angular/jquery, it is clear that the div generated using angular has caught my attention: <div id='my-div' style={{ang.style}}'> This is content inside the div </div> The style of the div is ...

Angular material: issue with alignment of table inside mat-expansion compared to other table

Hey there, I've encountered an issue on an Angular website where the columns in a table are not aligning properly. Does anyone have a solution for this problem? Thanks! <div class="table-responsive "> <table class="table" style=" ...

Creating a custom Koa.js server in a Next.js application

I'm facing an issue with my custom koa.js server. Whenever I try to make a request to the API, like /api/login I always end up getting a 404 not found error. I have searched for a solution but haven't been able to find one. Here is a snippet f ...

Guide to disabling file system routing for a particular page in Next.js

I'm trying to figure out how to block file system routing for only one specific page in nextjs. Despite attempting to use a Custom Server, the useFileSystemPublicRoutes : false option doesn't seem to work as some pages are still accessed through ...

Discover the power of Next.js by creating URLs with the format domain.com/category/post

I'm struggling to grasp the concept of dynamic URL routing that fits my specific needs, especially since most examples I find only cover structures like: domain.com/categories/category1, domain.com/posts/post-1. As indicated by the title, what I reall ...

Automatic Addition of Row Numbers Enabled

I'm currently exploring coding and experimenting with creating a scorekeeper for family games. I've managed to add rows dynamically and automatically sum up the entered information in the "total" row at the bottom. However, I'm facing an iss ...

What steps can I take to ensure that the information in my Cart remains consistent over time?

I recently built a NextJS application integrating the ShopifyBuy SDK. My implementation successfully fetches products from the store and displays them to users. Users can navigate to product pages and add items to their cart. However, I encountered an iss ...

An array of tooltips linked to specific areas on an image using

Hello, I have created an imagemap with area polygons that display tooltips when the mouse hovers over them. Additionally, there is a legend at the bottom of the image map. My goal is to show the tooltip on the specific polygon area when the mouse is hove ...

Tips for integrating Less and Bootstrap in an Angular 6 project

After making changes to angular.json to use less as the styleext, I tested it by creating a component. However, now I want to incorporate Bootstrap classes into my component's css/less. I specifically want all buttons in my component to have the .mx-1 ...

What is the best way to place a child on top of a different parent in the stack?

There is a collection of figure tags, each with an expandable figcaption. Inside each figure, there is a clickable div that reveals the figcaption when clicked. However, the visible figcaption only overlaps the figure it belongs to and not others. Is there ...

How to Style Background with CSS on the Server-Side? (Including Links and Hover Effects)

I'm facing a dilemma in choosing between an ASP.NET control and an HTML element for creating a button with a CSS-defined background that changes on hover... 1. Initially, it seems the ASP.NET ImageButton control is not suitable for this purpose becau ...

Positioning of buttons in Bootstrap 5 tables

I am working on a table that represents a CRUD application with details of a person and edit/delete buttons. The goal is to have these buttons displayed side by side, even on smaller screen sizes where they currently stack on top of each other. How can I ...