Use meta.apply and meta.get-mixin to allow "overriding" bootstrap mixins like button-variant #41242
Unanswered
web-cooking-factory
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I've got a common case. Most of the time, I need to change the way mixins like button-variant handle the variants generation.
In other words, I need to override the mixin. But, for now, the best solution I came with is to replace the original scss/_buttons.scss.
But what if the name of the mixin to apply is a variable ? This can be achieved through the sass:meta built-in module. I've just test it, It works pretty well and I think it's a nice solution. Also, applied properly, there would be no breaking changes.
So, let's take the button-variant case. We could add a scss/_mixins-variables.scss file containing this:
In scss/_buttons.scss, we actually have that:
Instead we could do something like this:
When using Bootstrap in a project, if my need is to change the default parameter values for instance, I can do a very simple thing:
It also offers a simple way to disable the variants generation, by setting:
$mixin-button-variant: null;
So, what do you think ? Maybe you already thought of it. For my concern, it would resolve a lot of my problems.
Have a nice day !
Beta Was this translation helpful? Give feedback.
All reactions