Basics of SCSS

Contents

  • Nesting
  • Variables
  • Using in React Component.

Basic layout

Nesting

hover element nested inside class with it’s css property

Building the class name with the nested hover inside. Keeping it cleaner and bit easier to read then the other way.

.className{
  &:hover{
   css-properties: property;
  }
}

What it compiles back down to.

.className{
  
}

.className:hover{
  css-properties: property;
}

Variable

animation showing theme scss being used in the component

Using SCSS in React Component

When building React Components

// React Component
import './style.scss'

class Header extends Component {
 render() {
    return (
            <div className={}>
            </div>
           )
}
//theme.scss

$variableA: #ffffff;
//style.scss

.divClass{
 color: $variableA;
}

Recent Posts