question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot customize style of ng-select in Angular

See original GitHub issue

Hi. I try to change the style of (ng-select) . I paste the revised style to the component style where ng-select is located.

    ng-select > div {
      border: 0!important;
      outline: none;
    }
    ng-select > div > div.single > div.toggle {
      color: #2ebaee!important;
    }
    ng-select > div > div.single > div.placeholder {
      text-align: center;
    }
    select-dropdown > div .filter {
      display: none;
    }

But it does not work. I inspect element on developer tools and see no my revised style. Interesting is when I paste the style to Angular Global stlye.scss . It works but it does not suit my me because it overrides all ng-select in my project. How to achieve changing design of ng-select in component? Thanks in advance!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
vugar005commented, Nov 8, 2017

solved this problem by adding a class to ng-select such as custom. Then in styles.scss

ng-select.custom > div { border: 0!important; outline: none; } ng-select.custom > div > div.single > div.toggle { color: #2ebaee!important; } ng-select.custom > div > div.single > div.placeholder { text-align: center; }

So again you need add those style to global styles.scss but this time it does not overwrite all ng-selects.

0reactions
istibekesicommented, Oct 26, 2018

Using ::ng-deep in parent component should work: For example, adding box-shadow on focus:

ng-select ::ng-deep .focus {
  border-color: #1268ff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 53, 145, 0.25);
}

However, I’m still wondering if is there any better approach for customizing the style.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to customize css for ng-select in angular? - Stack Overflow
I want to change the bottom border color when the select is opened by using ::ng-deep selector on ng-select. Thanks. css · angular...
Read more >
Can't change the style of .ng-select-container #1474 - GitHub
You can't override the style of .ng-select-container in a components stylesheet. I took a look at #718, but I am pretty sure my...
Read more >
SelectControlValueAccessor - Angular
Customizing option selectionlink. Angular uses object identity to select option. It's possible for the identities of items to change while the data does...
Read more >
Angular ng-select custom label cannot be click - StackBlitz
<p>Custom dropdown panel option template. using <b>ng-option-tmp</b></p>. <p>Last clicked: {{itemClicked}}</p>. <ng-select. [items]="cities".
Read more >
ng-select How to programmatically set a value
Topic: ng-select How to programmatically set a value ? ... Hope it fix your problem. ... import { Component, ViewChild } from '@angular/core';...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found