Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic2 Popover Change Width

I want to change the popover width of only 1 page. I tried this:

I do not want to use this $popover-ios-width in variable.scss files since it changes the width on all pages.

like image 228
Missak Boyajian Avatar asked May 16 '17 11:05

Missak Boyajian


People also ask

How do you use popover in ionic 5?

To present a popover, call the present method on a popover instance. In order to position the popover relative to the element clicked, a click event needs to be passed into the options of the the present method.


Video Answer


2 Answers

You can create a custom class for only this popover and pass it in the cssClass on it's options

let's say you have this:

.custom-popover {
  width: 60%;
}

In your popover creation you'll just insert it as the cssClass on the options

const customPopOver = this.popover.create({ yourPopoverPage, yourData, { cssClass: 'custom-popover'}});
customPopOver.present();

Hope this helps :D

like image 127
Gabriel Barreto Avatar answered Sep 19 '22 17:09

Gabriel Barreto


@gabriel-barreto's answer is totally fine. However, I guess it needs an additional consideration in other versions.

In Ionic 3.6 the custom class is added to the <ion-popover> element. In order to override the default width rule set in .popover-content class, your selector should be:

.custom-popover .popover-content {
  width: 60%;
}
like image 30
aperezbaena Avatar answered Sep 21 '22 17:09

aperezbaena