Skip to content

Instantly share code, notes, and snippets.

@silouanwright
Created March 7, 2024 17:05
Show Gist options
  • Save silouanwright/13c4549288cfd52007866574ccde8e47 to your computer and use it in GitHub Desktop.
Save silouanwright/13c4549288cfd52007866574ccde8e47 to your computer and use it in GitHub Desktop.

Revisions

  1. silouanwright created this gist Mar 7, 2024.
    22 changes: 22 additions & 0 deletions input.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    // Define SCSS variables with default values
    $header-color: purple;
    $font-size: 16px;

    // Create CSS custom properties with the same names and default values
    :root {
    --header-color: #{$header-color};
    --font-size: #{$font-size};
    }

    // Global class selector
    .brand-2024 {
    // Redefine CSS custom properties with desired values
    --header-color: red;
    --font-size: 18px;
    }

    // Use CSS custom properties in your styles
    h1 {
    color: var(--header-color);
    font-size: var(--font-size);
    }
    4 changes: 4 additions & 0 deletions markup.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    <div class="brand-2024">
    <h1>Hello Joe!</h1>
    </div
    >
    14 changes: 14 additions & 0 deletions output.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    :root {
    --header-color: purple;
    --font-size: 16px;
    }

    .brand-2024 {
    --header-color: red;
    --font-size: 18px;
    }

    h1 {
    color: var(--header-color);
    font-size: var(--font-size);
    }
    9 changes: 9 additions & 0 deletions settings.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    {
    "sass": {
    "compiler": "dart-sass/1.32.12",
    "extensions": {},
    "syntax": "SCSS",
    "outputStyle": "expanded"
    },
    "autoprefixer": false
    }