Using Multiple SCSS Files to Reference a Centralized Style Sheet

I am currently developing a React application and facing an issue with my SCSS files. I have three SCSS files, one main file that contains theme variable colors, and the other two are located in component folders.

When I import the main SCSS file into the contactForm styles.css and apply the variable color, everything works as expected. However, when I import the main SCSS file into the keepInTouchForm styles.scss, it disrupts the styling of the contactForm.

The question is why does this happen and what is the proper way to maintain one main.scss file with all variables and reference them across multiple SCSS files?

Below is my folder structure:

- components
-- contactForm
--- index.js
--- styles.scss

-- keepInTouchForm
--- index.js
--- styles.scss

- scss
-- main.scss

The main.scss file contains the following code:

$theme-colors: (
  'primary': #00a677,
  'secondary': #dde1e7,
);

Code inside styles.scss for the contactForm folder:

@import '../../scss/main.scss';

.form-control {
  border: 1px solid theme-color('secondary');
}

Code inside styles.scss for the keepInTouchForm folder:

@import '../../scss/main.scss'; //this breaks the above code

Answer №1

The syntax of <code>map-get has proven to be effective for my needs.

map-get($theme-colors, primary);

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

Can anyone suggest a method for retrieving the TablePagination component from MUI?

Is there a method to isolate and use just the TablePagination component from MUI without having to install the entire MUI library in my React project? I attempted to extract the TablePagination files from node modules, but encountered errors when trying t ...

What steps should I take to resolve the issue I am encountering while attempting to install packages using npm

npm ERR! Linux 4.15.0-36-generic npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "create-react-app" npm ERR! node v8.10.0 npm ERR! npm v3.5.2 npm ERR! path /tmp/npm-7054-19e3727d npm ERR! code EROFS npm ERR! errno -30 npm ERR! syscall mkdir n ...

Problems with WordPress Theme Rendering in Outdated Versions of Internet Explorer

Currently, I am developing a website for Chase on the Lake at http://chaseonthelake.com/. While everything looks perfect in FireFox, there are some display issues when viewing it in Internet Explorer. The dropdown transparency is not showing correctly, m ...

How can you use JavaScript to identify resize or zoom changes across all ancestor DOM elements?

I have a DOM element that consists of a chart. <div id="plot1" class='plot-chart'></div> This specific DIV can be nested within various other DIVs. <div id="one" style="width:100%;height:100%;zoom:0.9;"> <div id="two"& ...

Transparent dropdown elements using Bootstrap

I'm trying to incorporate a transparent bootstrap dropdown into my form. Specifically, I want the button itself to be transparent, not the dropdown list that appears when the button is clicked. Here's an example of what I currently have: https: ...

Tips for automatically adjusting a vertical side bar to fit between the browser's header and bottom

I'm having trouble with aligning my sidebar vertically between the header and the bottom of the browser window. Currently, the bottom items are extending beyond the browser's bottom edge. How can I adjust this to ensure proper alignment? Here is ...

Collection of HTML elements that need to stay in the same section

I am struggling to align multiple vertical lines of data on a webpage and keep them together when the page size changes. I've been working with CSS and HTML code but finding it challenging. Any suggestions or alternative approaches would be greatly ap ...

Visualizing nested data using dynamic line components in Recharts technology

Can the Recharts library handle nested keys? const data = [ { name: 'Sat Jan 1', curr: 4000, prev: 2400, }, { name: 'Sun Jan 2', curr: 3000, prev: 1398, }, ]; const data2 = [ { name: 'Sat Jan ...

Text below div will be displayed

When hovering over a div, an identical one will appear next to it with more information. Unfortunately, the content appears under the div but retains the styling like border-radius and background color. This is how my HTML looks: The div that needs ...

Having trouble pushing data to a GraphQL database from my Next.js application

I am currently working on developing a Reddit-like platform. To simplify the process, I have integrated SQL with graphQL using Stepzen for endpoints. Below is the code snippet of my Post Box component for the site, which includes graphQL mutations.ts and q ...

Ways to determine the count of selected checkboxes in React.js?

Recently, I delved into learning React. For one of my beginner projects, I decided to create a "life checklist" using Functional Components as the foundation. Just a heads up: I've structured data.js as an array of objects containing "action", "emoj ...

Executing a function from another module (File) within a React JS application

I am currently utilizing the Material UI v1.0.0-beta.33 in my project, which includes an App Bar component. import React from "react"; import PropTypes from "prop-types"; import { withStyles } from "material-ui/styles"; import AppBar from "material-ui/App ...

Live chat application experiencing issues with chat updates

I am currently developing a real-time chat application using socket.io for the server and React for the client-side code. Despite logging correct data in multiple consoles, I encountered an issue where new messages sent by one user are not automatically di ...

Tips for making text flow around an image

How can I achieve a design where the text wraps around an image positioned in the bottom right corner? [Image Removed by Owner] Your guidance on implementing this effect is greatly appreciated. Thank you. ...

Click on an item from the list and watch it magically change color with just one tap. [Next Js]

Is there a way to create a function that will only color the heart that is clicked on? I attempted to implement a function to display elements but it ends up coloring all the hearts when I click on one. Any suggestions on where the issue might lie? Here ...

Enhanced Firefox functionality with support for multiple columns

It has come to my attention that Internet Explorer 9 and older versions do not support multiple columns. However, even with the latest version of Firefox, I am experiencing issues with this website loading correctly. Do you have any insight into what might ...

The class styling is malfunctioning

When I click the 'night' button, I want the word color in the class=css to change to white. However, this is not working as intended, even though all other word colors are changing correctly. Here is my code: .css { font-weight: bold; ...

Having trouble changing the chosen selection in the material UI dropdown menu

I've encountered an issue with my material ui code for a select dropdown. It seems that the selected option is not updating properly within the dropdown. <FormControl variant="outlined" className={classes.formControl}> <InputLabel ref={ ...

D3.js is providing inaccurate tick numbers

Even though I specify that I want 3 ticks, I end up with 4 in my d3 js code The y-axis values I am working with are [2, 1, 3, 2, 4, 4, 6] svg .select(`[data-labels-y]`) .call(d3.axisLeft().scale(yScale).ticks(3).tickPadding(4))` My expected tick valu ...

React: Importing functions from other files is not allowed

As someone coming from an Angular background, I recently started using React and everything was going smoothly until I encountered an error while checking if Firebase is initialized: TypeError: _assets_Services__Firebase__WEBPACK_IMPORTED_MODULE_11__.defau ...