Guidelines for naming classes in scss when working with Next.js

Is it possible to use CSS naming conventions in SCSS files with Next.js and then import them into JavaScript using a different convention?

// login.module.scss file:
.login-button {
  // some scss styling
}

// Login.js file:
import styles from './login.module.scss'

<button className={styles.loginButton}>Login</button>

Edit: I am looking for a way to use a different naming convention in my JavaScript files while still keeping the original SCSS convention when working with Next.js.

Answer №1

It is generally recommended to use camelCase when naming your css/scss classNames. However, if you prefer to use kebab-case for your className, you can do so using bracket notation.

/* component.module.scss */

.login-button {
  /* some scss styling */
}
// component.jsx

<button className={styles['login-button']}>Login</button>

For more information, please refer to this link in the documentation.

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

Angular directive ng-if on a certain path

Is it possible to display a specific div based on the route being viewed? I have a universal header and footer, but I want to hide something in the header when on the / route. <body> <header> <section ng-if=""></section&g ...

Enhance Three.js 3D model visuals with textured surfaces using Fabric.js canvas as a dynamic texture

Exploring the world of Three.js for the first time, I am embarking on a project that involves leveraging a pre-existing 3D model and altering one of its materials to utilize a Fabric.js canvas as its texture. However, I've hit a roadblock where the te ...

What is the best way to display a loading animation until the entire wizard has finished loading in the jQuery-steps

I need help with implementing a loading animation using the jQuery-steps plugin in my wizard type form. I want the animation to be displayed until the entire wizard has loaded completely, but I'm unsure of how to enable this feature as there is a labe ...

Utilize AJAX, jQuery, and Symfony2 to showcase array information in a visually appealing table format

I have a requirement to showcase data utilizing ajax and jQuery in a table on my twig file. The ajax call is made with a post request to the controller, where the controller attempts to input several rows from a csv file into the database. However, there ...

Managing an extensive JSON file

With plans to create a project showcasing "UFO" sightings, I initially aimed to find an API for this but came up empty-handed. However, I stumbled upon a substantial 33mb JSON file containing reports of UFO sightings with over a million lines of code. Now, ...

An AJAX request receives a "400 Error: Bad Request" status code

Recently delving into the realm of jquery, I've encountered a 400 bad request error (identified in the browser console). $("form#upload").submit(function(){ var token = $("meta[name='_csrf']").attr("content"); var header = $("meta[name=&apo ...

How to integrate Firebase cloud functions into a React application

I am in the process of developing a React application, and I have successfully created a server cloud function: exports.myFunction = functions.https.onCall(async (data, context) => { ... } In previous projects, calling this server function from the c ...

Determine the hexadecimal color value by combining two different colors along with a specified percentage/position

Can a color in the middle of a gradient be calculated? var initialColor = 'FF0000'; var finalColor = '00FF00'; // At 50% between the two colors, it would result in '808000' var middleColor = determineMiddleColor(initialColor ...

Utilizing a method to nest schemas within schemas thanks to Mongoose

I am currently working on developing a blog that utilizes Node.js as the server-side language and integrates with Mongo DB. Within my blog, users will have the ability to create posts and interact through commenting, just like any typical blog platform. ...

The overflow property is not functioning as anticipated

I've browsed Google and this site, but I couldn't find a solution to my issue. On my webpage, I have a shoutbox and a teamspeak viewer with a specific height for the outer div. The scrollbars don't look good on our new design, so I attempt ...

Elevate a division within its container

Is there a way to make a smaller div positioned at the top when it's placed next to a larger one in the same container? I'm looking for a solution that doesn't involve using position-relative and manually adjusting the placement. Take a loo ...

Combine arrays if the objects inside them are identical

Is anyone online? I need help. I have an array structured like this. var array = [ { roomNumber: 'R01', roomType: 'Deluxe', basic_facilities: 'Hot Water', additional_facilities: 'Iron' }, { roomNumber: 'R01 ...

JavaScript for validating dimension text input has unique functionalities

I am looking for guidance on validating an ASP textbox using JavaScript. My goal is to validate a user's input in the format of 4-1/2, 80-1/2, 6/8, or simply 5. Only these types of patterns should be allowed, and each input must contain only one numbe ...

Bootstrap's nested grid system allows for intricate and dynamic layouts within

I am looking to design a grid with two columns, where on small and larger screens the width of the right column adjusts itself to accommodate its content, while the left column takes up the remaining space. On extra small screens, the layout changes to two ...

Angular triggers a function upon completion of several API requests

I am currently working on an Angular service that involves making HTTP calls. Here is an overview of the code structure: this.checkAndSendNotifications = function() { UsersService.getArray(function(array) { var notifications = []; angu ...

Can anyone explain the purpose of using the 'use client' function on all MUI components in Next.js 13?

Just starting out with react/nextjs development and I had the assumption that react components render on the server and are cached for quick access. However, if nextjs 13 converts all mui controls into client components, where does the rendering take plac ...

What could be causing my page width to only expand to 100% when using "fit-content"?

After searching extensively, I'm unable to find a solution that fits my current issue. My goal is to construct a practice ecommerce website using React. One of the components I have is a header which I'd like to occupy 100% of the screen width, c ...

Employ the express platform to refrain from responding to particular inquiries

Is there a way for my server to not respond at all when receiving a specific user-agent in the request header, while still serving HTML normally for other browsers? I tried different methods like using res.status(404).end() and res.destroy(), but they did ...

What is causing the fs.readFile function to give back undefined instead of the expected result?

/** * A function to determine the cost of an employee from a specific data file * @param {string} filePath - the path to the employee data file * @returns {{name: string, cost: number}} - the name and cost of the employee */ function calculateEmployee ...

Executing an asynchronous function in React within the same file

Having trouble calling the removeCouponCode method from the same file, as the execution claims it's not defined. I'm unsure of what might be missing here. Any suggestions? Below is the file I am working on and attempting to modify. Not entirely c ...