Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-select change dropdown arrow using image url

I am trying to use an image in assets folder to change the ng-select dropdown arrow.

there are references to make use of font-awesome like below - which is working

.ng-select .ng-arrow-wrapper .ng-arrow {
    display: none;
}

.ng-select span.ng-arrow-wrapper:before {
    content: "\f0ab";
    display: inline-block;
    font: normal normal normal 14px/1 FontAwesome;
    font-size: inherit;
    text-rendering: auto;
}

However, I am trying something like below to achieve it:

.ng-select ::ng-deep .ng-arrow {
  display: none;
}
.ng-select ::ng-deep .ng-arrow-wrapper {
  height: 14px;
  width: 14px;
  background-image: url('../assets/arrowhead-down.svg');
  background-repeat: no-repeat;
  margin-right: 12px;
  margin-left: 10px;
  margin-top: 5px;
}
.ng-select-opened ::ng-deep .ng-arrow-wrapper {
  background-image: url('../assets/arrowhead-down.svg');
}

However, this isn't rendering the assets image. Appreciate any inputs.

This is the caret I am using for dropdown arrow

^^ this is the image caret I am using for dropdown arrow

The problem for me here is not the usage of assets. I am trying to get the background image url work (it could be any url). The reason being I am using angular elements where one of the element will be using this ng-select. Since, these elements will be part of a javascript import, I cannot have it as part of assets. So, I am trying to make use of background image from our hosted CDN. However, I am unable to get the image to show up in the dropdown

Thanks, Ani

like image 629
Anirudh Reddy Kontham Avatar asked Oct 15 '25 18:10

Anirudh Reddy Kontham


1 Answers

I understand what the OP wanted to do here is the answer - I tried it and it works.

.ng-select .ng-arrow-wrapper .ng-arrow {
  border-color: none !important;
  border-style: none !important;
  border-width: 0 !important;
}
.ng-select .ng-arrow-wrapper {
  background-image: url('/assets/img/arrowhead-down.svg');
  background-repeat: no-repeat;
  background-size: 14px 14px;
  margin-top: 2px;
}

originally I had posted a different answer but I understood what the issue was - however, the assets path should always be preceded by a / at the root. You did not need to use ng-deep.

like image 92
chris burd Avatar answered Oct 18 '25 10:10

chris burd