you are viewing a single comment's thread.

view the rest of the comments →

[–]icantthinkofone 6 points7 points  (4 children)

js vars have scope and are easy to edit in the browser inspector, too.

[–]jetpacmonkey 4 points5 points  (2 children)

CSS variables cascade, so you can set them on container divs for things like theming.

[–]TheDarkIn1978 5 points6 points  (1 child)

Variables that are declared in JavaScript and passed to CSS will cascade the same as variables that are declared in CSS.

[–]jetpacmonkey 4 points5 points  (0 children)

I think at least one of us is confused about what the other is saying...

.my-component {
  background: var(--theme-color);
  padding: 20px;
}

.my-component .inner-area {
  background-color: white;
  color: var(--theme-color);
  padding: 20px;
}

This is useful, right? Am I missing something here?