@extend directive does in Sass.The @extend directive allows one selector to inherit the styles of another by merging their CSS rules. This helps avoid duplication and keeps the CSS smaller.
@extend to make .button-primary share styles from .button.The correct syntax is @extend followed by the selector to inherit from, without quotes or parentheses.
.alert { border: 1px solid red; padding: 1rem; } .error { @extend .alert; background: pink; }
The @extend directive merges selectors sharing the same styles into a single CSS rule. So .alert and .error share the border and padding styles in one rule, while .error adds its own background style separately.
.card?.box { padding: 1rem; } .container .box { margin: 2rem; } .card { @extend .box; }
The @extend directive matches selectors that include the target selector. It will extend .box and .container .box but not .container alone because it does not include .box.
@extend?Improper use of @extend can merge unrelated selectors, causing styles to apply where they shouldn't. This can confuse assistive technologies like screen readers if semantic class names lose their distinct styles.