Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select2 multiple select changing style of selected values

I am looking to try and format or change the style of the selected items from a select2 selection. That is when you use select2 on multiple selections (dropdown select option field), the options you choose jump into a multiple selection box with a little x on them to remove if you choose.

I am trying to format these chosen selections (see image) so that the page looks neater. Trying to make the font smaller and the background color a different color, struggling... Selected options

Can anyone assist in this regard?


2 Answers

You can override the given file css files with respect to the given file https://github.com/select2/select2-bootstrap-theme/blob/master/docs/css/select2-bootstrap.css

here is some useful css selectors with styles for that:

.select2-selection__choice{
    margin-top: 0px!important;
    padding-right: 5px!important;
    padding-left: 5px!important;
    background-color: transparent!important;
    border:none!important;
    border-radius: 4px!important;
    background-color: rgba(0, 139, 139, 0.09) !important;
}

.select2-selection__choice__remove{
    border: none!important;
    border-radius: 0!important;
    padding: 0 2px!important;
}

.select2-selection__choice__remove:hover{
    background-color: transparent!important;
    color: #ef5454 !important;
}
like image 35
Mehran Nasr Avatar answered Dec 14 '25 00:12

Mehran Nasr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!