What if you could fix a style once and see it change everywhere instantly?
Why Mixin definition with @mixin in SASS? - Purpose & Use Cases
Imagine you are styling a website and need to reuse the same button style on many pages. You copy and paste the same CSS code for each button.
If you want to change the button style later, you must find and update every copy manually. This is slow and easy to miss some places, causing inconsistent styles.
Using @mixin lets you write the button style once and reuse it everywhere by including the mixin. Change it once, and all buttons update automatically.
button {
background: blue;
color: white;
padding: 1rem;
}
/* copied many times */@mixin button-style {
background: blue;
color: white;
padding: 1rem;
}
button {
@include button-style;
}You can write styles once and reuse them easily, making your CSS cleaner and faster to update.
A website with many buttons that all share the same look can use a mixin to keep their styles consistent and easy to maintain.
Manually copying styles causes errors and slow updates.
@mixin lets you define reusable style blocks.
Updating a mixin updates all places where it is used.