Milligram: Easily change highlight color (#9b4dca)

Created on 22 Feb 2018  ·  6Comments  ·  Source: milligram/milligram

Using CSS3 variables (custom properties) it is possible to override the highlight color in 1 line of CSS.

In milligram.css have something along the lines of:

:root {
  --highlight-color: #9b4dca;
}

and then replace every #9b4dca with var(--highlight-color).

Once this is done, replacing the highlight color is as easy as including a custom.css file with

:root {
  --highlight-color: #abcabc;
}
Hacktoberfest new feature

Most helpful comment

I came here for the same thing ^^ but since it is written in SASS and you might want to support old browsers I would recommend doing a more fallback proven example like this:

button {
  background-color: $color-primary;
  background-color: var(--color-primary, $color-primary);
}

This way browsers who don't support CSS custom properties will still fallback to a working version. Also this way no :root {} in the actual stylesheets is needed since var() already provides a fallback option.

Cheers,
Dominik

All 6 comments

I came here for the same thing ^^ but since it is written in SASS and you might want to support old browsers I would recommend doing a more fallback proven example like this:

button {
  background-color: $color-primary;
  background-color: var(--color-primary, $color-primary);
}

This way browsers who don't support CSS custom properties will still fallback to a working version. Also this way no :root {} in the actual stylesheets is needed since var() already provides a fallback option.

Cheers,
Dominik

Is their any progress or anything done on this so far? 😄

Is their any progress or anything done on this so far? 😄

you can always change the values of the colors from the src/_Color.sass and then recompile again with sass --update. You can also add your own sass files.

Is their any progress or anything done on this so far? 😄

you can always change the values of the colors from the src/_Color.sass and then recompile again with sass --update. You can also add your own sass files.

Good point! I guess I'm looking for a bit more out-of-the-box solution since I don't use Sass, but I don't really know how that could be easily done other than changing the values themselves in /dist/milligram.min.css which would be problematic.

Love this framework! Can't wait for this feature to be released 🚀

Hey @mterron @dkundel @timrossback @dntzbgh @cilim

Maybe something like this?
https://github.com/milligram/milligram/pull/262/files#diff-7b0a61514569d183adbda861549f9d98

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roryprimrose picture roryprimrose  ·  7Comments

PurpleBabar picture PurpleBabar  ·  6Comments

negativefix picture negativefix  ·  7Comments

westtrade picture westtrade  ·  10Comments

fooksupachai picture fooksupachai  ·  5Comments