On a site I'm developing w/ Bootstrap/SASS (SCSS) I'd like to have a Bootstrap button group (.btn-group
) become a vertical group (.btn-group-vertical
) using media selectors, rather than JavaScript. However, the well-known issues that @extend
will not work inside a media selector, has left me befuddled. E.g., this raises an error:
.navGroup {
@extend .mt-1;
@extend .btn-group;
@include media-breakpoint-down(xs) {
@extend .btn-group-vertical;
}
}
If I were developing from scratch I'd rewrite .btn-group
and .btn-group-vertical
to simply @include
a mixin, so that I could do something like:
.navGroup {
@extend .mt-1;
@include media-breakpoint-up(xs) {
@include btn-group-include();
}
@include media-breakpoint-down(xs) {
@include btn-group-vertical-include();
}
}
I would rather not change the original bootstrap _buttonGroup.scss
file, since it will be overwritten at the next release/update. So I'm currently needing to copy and past the whole .btn-group-vertical
definition:
.navGroup {
@extend .mt-1;
@extend .btn-group;
@include media-breakpoint-down(xs) {
flex-direction: column;
align-items: flex-start;
/* etc. for 70 lines */
}
}
Is there a way to easily convert an existing class definition into a mixin within Sass that would solve such a problem?