Is possible change colors on-the-fly without compile? #2123
Replies: 3 comments 9 replies
-
If you want to create FUI style classnames for new colors (mintgreen, moonblue, etc.) you have to recompile, because the colors are build into each element out of the central colors.less file The FUI approach is to declare a color name which affects all elements. But as many elements have different shades of colors in parts of their appearance this is not a single color to be taken care of. What exactly is your use case to change colors of each element on the fly? If it's only for a single element, you might try to use css variables only for that. |
Beta Was this translation helpful? Give feedback.
-
If it's only for colors then try to use CSS Variables directly in the central color file |
Beta Was this translation helpful? Give feedback.
-
I will try to explain my use case in more detail: I have a platform that any user, via the configuration panel, can choose any color using a color picker. With any color chosen, I would like to apply the same color to a FomanticUI element dynamically. For example, the user chooses a specific color #456389 and that color is dynamically applied to the primary button (#456389 - this color is purely hypothetical). When you said to use CSS variables, I could see in the CSS documentation that I can define a variable in one CSS file and then in another CSS file get the value of this variable. So, when my user makes a choice of color, I create a variable.css file with the definition of this value. So I create the following 'variables.css' file with this reference:
Then I need to reference this same color in 'semantic.css' somehow so that this color can be dynamically read by FomanticUI. In the previous case, I tried to do this using site.variables . But for some reason, LESS does not support reading CSS variables in the format "var(--variable-name)" as per the CSS documentation like this case I tried to compile:
So, is there any way to reference these dynamic colors in FomanticUI without having to compile? In other words, modify colors on-the-fly without having to define predefined color palettes? |
Beta Was this translation helpful? Give feedback.
-
I want to create some kind of color picker to my users change colors in the application and apply it to Fomantic UI (2.8.8). I can't found any kind of examples that do that in the documentation or here. I only found forms to change themes colors when it's on developer ambient. So, to change colors I need to compile CSS always. This is good to prepare application, but to change colors dynamic isn't. It was my mistake or there are some form to do that?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions