bluebomber
bluebomber

Reputation: 51

Invalid Sass variable when using number (with and without px)

I am using Sass for a project and I ran into an issue with variables. I'm specifically using the ".sass" format and not ".scss"

The error says: Invalid variable: "$weightBold = 700"

I can use variables for colors like this "$darkGrey: #333333" without errors, but I do get an error when I try to use a number for font-weight "$weightBold = 700" or width "$mediumWidth = 300px"

Upvotes: 1

Views: 632

Answers (2)

Sebastian Brosch
Sebastian Brosch

Reputation: 43594

You need to use : instead of = to assign a value to the variables:

$weightBold: 700;
$darkGrey: #333333;
$mediumWidth: 300px;

You can see some examples on the official documentation:

The most straightforward way to use SassScript is to use variables. Variables begin with dollar signs, and are set like CSS properties.

$width: 5em;

Upvotes: 1

Khal
Khal

Reputation: 76

There is nothing wrong with the number, use : instead of =

Upvotes: 4

Related Questions