I was adding some variables to my CSS file, and I seem to have broken it. I have never used variables in CSS before (im not much of a front-end guy), so I dont know, if I did something wrong or the parser is acting up, because the error I'm getting seems non-sensical in consideration of where it occurs:
Mar 26, 2023 11:16:27 PM javafx.css.CssParser parse
WARNING: CSS Error parsing jar:file:///D:/Projects/jfxtest3/build/libs/jfxtest3-1.0-SNAPSHOT.jar!/com/example/jfxtest3/main.css: Expected RBRACE at [4,4]
Here is the code that caused this:
:root
{
--rosewatercol: #f5e0dc;
--flamingocol: #f2cdcd; <-- according to the error, there should be a closed bracket at pos 4 in this line
--pinkcol: #f5c2e7;
--mauvecol: #cba6f7;
--redcol: #f38ba8;
--marooncol: #eba0ac;
--peachcol: #fab387;
--yellowcol: #f9e2af;
--greencol: #a6e3a1;
--tealcol: #94e2d5;
--skycol: #89dceb;
--sapphirecol: #74c7ec;
--bluecol: #89b4fa;
--lavendercol: #b4befe;
--accentcol: --tealcol;
--textcol: #cdd6f4;
--subtext1col: #bac2de;
--subtext0col: #a6adc8;
--overlay2col: #9399b2;
--overlay1col: #7f849c;
--overlay0col: #6c7086;
--surface2col: #585b70;
--surface1col: #45475a;
--surface0col: #313244;
--basecol: #1e1e2e;
--mantlecol: #181825;
--crustcol: #11111b;
}
.root
{
-fx-background-color: linear-gradient(from 0% 0% to 100% 100%, #181825, #1e1e2e);
-fx-border-style: none;
-fx-border-width: 0;
-fx-border-insets: 0;
}
.root *
{
-fx-font-size: 18;
-fx-text-fill: --textcol;
-fx-fill: --textcol;
-fx-border-style: none;
-fx-border-width: 0;
-fx-border-insets: 0;
-fx-background-radius: 12;
}
.button
{
-fx-background-color: --surface0col;
-fx-font-size: 18;
-fx-text-fill: --textcol;
-fx-fill: --textcol;
}
.button:hover
{
-fx-background-color: --surface1col;
}
.vbox
{
-fx-background-color: --surface0col;
}
.hbox
{
-fx-background-color: --surface0col;
}
.accordion
{
-fx-background-color: --surface0col;
}
.titled-pane > .title
{
-fx-background-color: --surface0col;
-fx-background-insets: 0;
-fx-border-style: none;
-fx-border-width: 0;
-fx-border-insets: 0;
}
.titled-pane > .title > *.text
{
-fx-fill: #fff;
}
.titled-pane > .content
{
-fx-background-color: --surface0col;
-fx-border-style: none;
-fx-border-width: 0;
-fx-border-insets: 0;
}
What did I do wrong and how do I fix this?
I've found the answer. JavaFX doesn't actually support variables, only non-standard looked-up colors. They only start with one hyphen, and doesn't live in :root, but .root. And as the name implies, they only work for colors, nothing else.
Here is the code from above changed to work with looked-up colors: