F
F
furashcka2016-02-09 13:30:41
css
furashcka, 2016-02-09 13:30:41

Sass mixin for select2 customization, is there one already?

Hello! For dropdown lists I use Select2
To change the appearance I set the theme:

$(".js-example-theme-single").select2({
    theme: "example"
});

And after I set the styles through (sass):
.select2-container--example {
    /*
    и тут задаю дочерним элементам стили
    */
}

This method takes about 30 minutes in time and, as for me, causes code duplication, each time I write the same selector names, with the exception of .select2-container--example, if more than 1 drop-down list is used on the page ...
There is an idea to do mixin... where to set only the modifier class .select2-container--example and styles, the question itself. Am I reinventing the wheel? Are there ready-made mixins for this task? Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dima Barsukov, 2016-02-09
@mrsombre

You probably need to set the theme globally $.fn.select2.defaults.set("theme", "classic");
And in css to use a more general selector?

A
askouev, 2020-12-29
@askouev

Isn't it possible to immediately edit the included CSS file of this plugin?
I converted this file to SASS, edited it, and it already gets into the general compiled CSS. Everything is working.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question