1. CSS Custom Properties A short talk at BrooklynJS 19 July 2018 by Tyler Gaw

  2. CSS is good A graphic of the words CSS is good repeated vertically

    Let's start here. I'll make a couple quick mentions of JavaScript, but this talk is about CSS. It's good and keeps getting better. We're in a time when “right now” is always the best time for CSS. This is thanks to numerous individuals and groups putting in mostly thankless hours to make sure CSS keeps getting better.

  3. Basic Usage

    You define custom props within any selector using the double dash "--" prefix followed by any valid characters. Valid characters are any chars not used in other parts of CSS like brackets "{}". You might see examples with custom props defined in a :root selector. That works, but you don't have to define them there. Property names are case-sensitive.

  4. Not Variables

    CSS Custom Properties are often referred to as "variables." That's easiest to say, but it's important to understand they work like variables like you're used to in other languages. Custom props can't be used in CSS selectors. And they can't be used for string interpolation. As of right now, the best way to think of them is custom property values. You use them to store and re-use CSS property values.

  5. Scope

    Custom props have block scope. So defining a property within the .sibling-of-slide-4 selector means it won't be available in a .slide-4 selector.

  6. Defaults

    The var function takes an second–optional–argument. A default value to use in case the requested property is undefined.

  7. Inheritance

    The var function takes an second–optional–argument. A default value to use in case the requested property is undefined.

  8. Media Queries

  9. Values

  10. Values

  11. Values

  12. Animation?

  13. const style = getComputedStyle(document.body);
    style.getPropertyValue('--bg-color'));

    JS Access

  14. document.querySelector('body')
      .style.setProperty('--title-fill', 'orange');

    JS Access

  15. https://bkjs0718-custom-props.glitch.me
    Remix on Glitch
    Thank you