Error BOOTSTRAP SASS _is not a color for `Darken'

Asked

Viewed 111 times

1

This error returns when I sort these @import files in my app.scss, using SASS/[email protected] on a Mac. I need to understand where the error is, if by reversing the order (custom variables at the end) the error does not happen, and if there is a problem keep this last order (no error):

error Sass/_variable.scss (Line 176: $color: "Theme-color(#007bff)" is not a color for `Darken')

// imports
@import "../sass/variable"; // Bootstrap variables
@import "../node_modules/bootstrap/scss/bootstrap";  // Bootstrap framework
@import "../node_modules/bootstrap/scss/functions";  // Bootstrap Functions - custom

error-free:

// imports
@import "../node_modules/bootstrap/scss/bootstrap";  // Bootstrap framework
@import "../node_modules/bootstrap/scss/functions";  // Bootstrap Functions - custom
@import "../sass/variable"; // Bootstrap variables

1 answer

1


Look it is difficult to explain why the mistake without knowing what you did there. But the documentation helps a little to clarify things... You’ve probably changed some Mandatory Key

For example, we use the Primary, Success and Danger keys of the $Theme-Colors map, for links, buttons and form states. Replacing the values of these keys should not present problems, but removing them can cause problems in the Sass build.

Behold: https://getbootstrap.com.br/docs/4.1/getting-started/theming/#keys-bond%C3%B3rias


About reversing the order of your variables the indicated would really be they come before as the documentation says, but if you changed the variables directly in variable.scss your problem may be related to what you said earlier about the Keys.

Anyway, in case you have touched this file see that the documentation itself does the @import of variables after the functions

//Partes obrigatórias
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";

// Partes opcionais
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";

Behold: https://getbootstrap.com.br/docs/4.1/getting-started/theming/#importing

Then changing the order may not present unwanted effects. Although I recommend running some tests with some components etc to confirm that the CSS will load as expected...


OBS: Also, all Bootstrap variables have the flag !default, this means that you can safely override the value of this variable. Your . scss would look like this: (but in your case may not solve if the value you changed was directly in the Bootstrap default variable)

// Suas sobrescrições de variáveis
$body-bg: #000;
$body-color: #111;

//Partes obrigatórias
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";

See more here: https://getbootstrap.com.br/docs/4.1/getting-started/theming/#Vari%C3%A1veis-padr%C3%A3o

  • First thank you for the full and detailed reply! Now I haven’t changed anything, I just created a new variable file by copying the original variables, where I can edit and thus not change the pattern. After the installation via npm of Sass, bootstrap, jquery and Popper all works well, but it was necessary to comment on @import _root for now, but I know that is not the option I should use. I use Visual Studio Code and its terminal, so I have a unique and clean interface to work on Mac or Windows.

  • 1

    @Eduardocorreia guy I tested here and I got it. In fact you can do in several ways tried here and everything worked out, the only problem even was when I tried to change a color directly inside the _variable.scss ai it the same dick. But if you take some variable that’s in there and put it into a novacor.scss and import before the /node_modules/bootstrap/scss/variables or the full /bootstrap will work. Last This can help you a lot!! https://www.youtube.com/watch?v=6Ovw43Dkp44

  • Check it out, this is the video I used as a reference! I didn’t change any color. I just copied and saved it as a new file. I’ve seen other people with the same situation. I haven’t solved it yet, but I’ll try to redo everything to make sure nothing went wrong. If you know anything new about this, I’d appreciate your help.

  • 1

    @Eduardocorreia guy I tested on my own and tested tb as the video guy and had no problems. Since you are starting from 0, install Bootstrap and do not touch ANYTHING on it, then you create a . CSS that will be the only one. CSS that you will index on your page, and on . SCSS of this . CSS vc does so http://prntscr.com/mxrh2x or if you prefer you can do so: http://prntscr.com/mxrhq6 where this is minhacor is a scss where you will have your color variables changed that you copied from _variables original Bootstrap. That’s basically it, here it worked both ways

Browser other questions tagged

You are not signed in. Login or sign up in order to post.