Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need custom Css class option for Dropdown/Datepicker similar to Tooltip #3626

Closed
FirstVertex opened this issue Feb 26, 2020 · 7 comments · Fixed by #4041
Closed

Need custom Css class option for Dropdown/Datepicker similar to Tooltip #3626

FirstVertex opened this issue Feb 26, 2020 · 7 comments · Fixed by #4041

Comments

@FirstVertex
Copy link

FirstVertex commented Feb 26, 2020

I need to assign a custom Css class to the dropdown of Dropdown and Datepicker. Need similar api to existing tooltipClass option for Tooltip. We are using container="body" for both Dropdown and Datepicker and sometimes we need to assign custom theme coloration to the Dropdown and Datepicker via a Css class.

I also noticed that Modal and Popover already have a similar Css class option.

Thanks!

@FirstVertex
Copy link
Author

It could be similar to #2984

@gpolychronis
Copy link
Contributor

@hughanderson4
You can add a custom class on Dropdown. No change is needed on ng-bootstrap side. i.e:

  <div ngbDropdownMenu aria-labelledby="dropdownBasic1" class="custom-class">
    <button ngbDropdownItem>Action - 1</button>
    <button ngbDropdownItem>Another Action</button>
    <button ngbDropdownItem>Something else is here</button>
  </div>

and css:

  .custom-class {
      background-color: pink;
  }

@dasco144
Copy link

I have a similar issue but I need to override the z-index of the div.dropdown element created on the body to fix an issue where the dropdown is appearing behind the popover that has the drop down toggle.

image

Is there perhaps another way to target this div.dropdown element on the body to add this z-index?

@azerafati
Copy link

I do have a workaround for this until it is implemented.

  1. Reference dropdown in the component that is using it
@ViewChild(NgbDropdown)
dropdownElement: NgbDropdown;
  1. Put a (openChange)="setDropDownOpenState($event)" on ngbDropdown and :
setDropDownOpenState(isOpen: boolean) {
  if (isOpen) {
    this.dropdownElement._menuElement.nativeElement.parentElement.classList.add('custom-dropdown');
  }
}


@maxokorokov maxokorokov added this to the 9.1.0 milestone Mar 10, 2021
@maxokorokov
Copy link
Member

Datepicker → #4039

@FirstVertex
Copy link
Author

❤️

@DoimoInterlogica
Copy link

DoimoInterlogica commented Oct 26, 2023

Action - 1 Another Action Something else is here

This just adds that class to the button that opens the dopdown, not the dropdown itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants