Using Content Blocks with @content in Sass
📖 Scenario: You are creating a reusable button style in Sass. You want to allow different buttons to have custom inner styles or content blocks using @content. This helps keep your styles clean and flexible.
🎯 Goal: Build a Sass mixin called button-style that applies basic button styles and accepts a content block with @content to add extra styles inside the button.
📋 What You'll Learn
Create a mixin named
button-style with basic button stylesUse
@content inside the mixin to allow custom inner stylesInclude the mixin in a class
.btn-primary and add extra styles using the content blockEnsure the final CSS styles the button with base and custom styles
💡 Why This Matters
🌍 Real World
Using @content in Sass mixins helps create flexible, reusable style blocks for UI components like buttons, cards, or alerts.
💼 Career
Front-end developers often write Sass mixins with @content to keep CSS DRY and maintainable while allowing customization.
Progress0 / 4 steps