Variable in SCSS not being applied as expected

I'm currently grappling with understanding why my alterations to the system colors aren't reflecting as expected.

When viewing in Chrome, this is the image I see.

https://i.sstatic.net/H6YbW.png

However, this is what I anticipate should be visible.

https://i.sstatic.net/Jncdj.png

In my Angular project, I have three files: variables.scss, bootstrap.scss, and branding.scss. Below is how they are imported in the main styles.scss file.

This is my import list.

@import "styles/variables";
@import "../../../node_modules/bootstrap/scss/bootstrap";
@import "styles/branding";

A snippet of my variables file:

/* =====================================
    General Colours
===================================== */
$color-black: rgb(0,0,0);
$color-white: rgb(255,255,255);
...

/* System Tints
===================================== */
$color-lm-blue:     #007AFF;
$color-lm-green:    #34C759;
$color-lm-indigo:   #5856D6;

Finally, here is my branding.scss content:

:root {
    ...
}

html,
body {
        background-color: var(--bg-primary-color);
        color: var(--color-text);
}

/* Button Classes
===================================== */
...

I'm baffled by why the changes are not being applied. Upon inspecting with Chrome's developer tools, I noticed a discrepancy in the button class appearance.

Here is the button class image:

https://i.sstatic.net/Nbj8j.png

And here is Bootstrap's colors:

https://i.sstatic.net/NXonE.png

While I plan on incorporating light and dark themes in the future, that's a project for later. Any assistance would be greatly appreciated.

Answer №1

For your specific needs, there is a distinct syntax available: https://sass-lang.com/documentation/breaking-changes/css-vars

$primary-color: #42b983;

:root {
  // INCORRECT, will not function in more recent versions of Sass.
  --primary-color-incorrect: $primary-color;

  // CORRECT, will work across all Sass versions.
  --primary-color-correct: #{$primary-color};
}

To ensure proper transpilation, make sure to enclose your SCSS variables like #{$color}.

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

Passing a variable between two PHP files and then showcasing its value in a separate third file

bookincome.php receives several inputs, and bi.php calculates the total net income based on the values provided by bookincome.php. It then displays a table containing all the user-given values and the calculated total book income ($tnibeforetax) value. How ...

Include a border around the entire tooltip

I'm having trouble adding a border to my tooltip that follows the outer lines of the entire tooltip. Currently, I've only been able to add a border to the upper part of the tooltip, which overlaps with the arrow section and isn't the desired ...

Textfield with autocomplete dropdown

I have a text field on my website that needs to work as an autocomplete box. I have included the following code in the "headerbar" section of my page: Find :<input type="text" class="input2" style="margin-bottom:0px;" id="customersearchfield"> < ...

The object assigned in the Facebook login method cannot be utilized

I'm working on integrating Facebook login with Angular 2. Here's the button for logging in: <button ion-button (click)="fbLogin()"><ion-icon name="logo-facebook"></ion-icon>Login using Facebook</button> Below is the clic ...

Change the default direction of content scrolling in CSS and JavaScript to scroll upwards instead of

I am currently working on a website where the navigation bar spans the entire width and remains fixed in place. Below the navigation bar is a cover image, followed by the main content section. As you scroll down, the navigation bar covers the image from t ...

Creating a basic popup with jQuery: A step-by-step guide

Currently in the process of creating a webpage. Wondering how to create a popup window with an email label and text box when clicking on the mail div? ...

Transform the string property extracted from the API into a JSON object

When making a request to an API, the data returned to the front end is in the following format: { name: 'Fred', data: [{'name': '"10\\" x 45\\" Nice Shirts (2-pack)"', 'price' ...

Locate grandchildren elements using getElementById

My task is to modify the content and attributes of the table. The DOM structure is generated by a third-party tool, and I am using JavaScript to make changes in various sections. <div id="myId"> <div> <div> <table&g ...

Customizing Your WooCommerce Storefront: Tips for Enhancing Your Product Catalog and Minimizing White Space

Lately, I've been working on enabling a product filter in the left sidebar of my Woocommerce theme. However, I have noticed that the layout is not quite how I would like it to be. Take a look at this image that shows the changes I am aiming for. Cur ...

Unforeseen outcomes when setting background colors with Anime.js

I've recently started experimenting with Anime.js. I have a piece of code that I'm using to animate a div element with an id of a. anime({ targets: "#a", translateX: 250, color: "#fff", backgroundColor: "hsl(200, 50%, 50%)", ...

The bootstrap card layout breaks with Google Maps in Chrome and is not functioning properly

I have encountered an issue with the bootstrap card layout and Google Maps integration. When I move the Google Map to a card in a right column, it does not display properly. However, placing it in the first column works perfectly fine. This problem seems t ...

Gather keyboard information continuously

Currently working with Angular 10 and attempting to capture window:keyup events over a specific period using RXJS. So far, I've been facing some challenges in achieving the desired outcome. Essentially, my goal is to input data and submit the request ...

What is the best way to align the bottom of the last child of a flex element?

Current: https://i.sstatic.net/e7V8x.png Desired: https://i.sstatic.net/Xszod.png Is it possible to achieve this using the flex or grid model, or do I need to reconsider the structure with a different approach? Below is the code snippet: .sections { ...

Techniques for determining if a file is empty using jQuery

Just starting out with JS. I want to validate the file input element before form submission using jQuery/JavaScript. I've researched various solutions, but nothing seems to be working for me. I'm trying to avoid displaying "/c/fakepath" as the ...

Encountering an issue stating "The element is not visible at the moment, therefore cannot be interacted with" while trying to access a text box within a window opened via an ajax call

Currently, I am working on a Selenium script using Java to automate a specific process. However, I have encountered an issue where clicking on a dropdown causes a hidden popup to appear through an ajax call. Unfortunately, when attempting to interact with ...

Navigate div containers interchangeably

Take a look at what I made: https://jsfiddle.net/1qsoL695/ This is the HTML code: <div class="container"> <div id="select"> <div>ONE</div> <div>TWO</div> <div>THREE</div> &l ...

Which client architecture is most suitable for an LCD wall application?

My task is to create a large LCD wall application similar to the one featured in this advertisement. The requirements include the ability for the wall to display full-screen videos or divide the screen into sections to show multiple videos or images. I a ...

Is the component experiencing issues with its style functionality?

I am attempting to add CSS styles to app.component.ts using the :host property, but I am not seeing the desired results. The CSS is being applied, but not correctly. .ts export class AppComponent { title = "Default Title" data = 'This is defaul ...

What is the best way to ensure that text fields remain hidden upon page load until the appropriate drop down option is chosen?

Is it possible to initially hide text fields and only reveal them when a specific drop down option is selected? The current JavaScript code somewhat achieves this, but I would like the input fields to remain hidden by default. <script language=" ...

Exploring the capabilities of extending angular components through multiple inheritance

Two base classes are defined as follows: export class EmployeeSearch(){ constructor( public employeeService: EmployeeService, public mobileFormatPipe: MobileFormatPipe ) searchEmployeeById(); searchEmployeeByName(); } ...