Skip to content

How do i add up and down arrow based on p-dropdown menu open #26

Answered by yigitfindikli
mdnafeed asked this question in PrimeNG
Discussion options

You must be logged in to vote

Hi @mdnafeed!

You can add custom icons in multiple ways:

1-) You can access the p-dropdown with ViewChild and use the overlayVisible property for the check.
Demo: https://stackblitz.com/edit/kbepji?file=src%2Fapp%2Fdemo%2Fdropdown-basic-demo.ts

2-) You can use emitters of p-dropdown. Create a local boolean something like dropdownVisible.

  • onShow => dropdownVisible = true;
  • onHide => dropdownVisible = false;

Apply icons:

get getDropdownIcon() { return this.dropdownVisible ? 'pi pi-caret-up' : 'pi pi-caret-down'; }

<p-dropdown ... [dropdownIcon]="getDropdownIcon"></p-dropdown>

3-) You can use dropdownicon template

Regards.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@mdnafeed
Comment options

@yigitfindikli
Comment options

Answer selected by mdnafeed
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants