Why Mixins Eliminate Duplication in Sass
📖 Scenario: You are creating styles for a website with multiple buttons that share common styles but differ slightly in color.
🎯 Goal: Build a Sass stylesheet that uses a mixin to avoid repeating button styles and apply it to different button classes with unique colors.
📋 What You'll Learn
Create a mixin named
button-style that sets padding, border-radius, and font-sizeCreate a variable named
$primary-color with the value #3498dbUse the
button-style mixin inside a .btn-primary class and set its background color to $primary-colorUse the
button-style mixin inside a .btn-secondary class and set its background color to #2ecc71💡 Why This Matters
🌍 Real World
Web designers often style many buttons or components with similar styles but different colors or sizes. Mixins help keep the code DRY (Don't Repeat Yourself).
💼 Career
Knowing how to use Sass mixins is important for front-end developers to write efficient, maintainable CSS for large projects.
Progress0 / 4 steps