Popover styling

I am trying to use popOver on a page with the popOver having a few icons. Everything is working fine except that I cannot increase the width of the popover and I get a scroll bar at the bottom if I increase the width in the style sheet.

I am using ionic2 with the following method:

presentPopover(myEvent) { 
   let popover = Popover.create(PopoverPage); 
   this.nav.present(popover, { 
     ev: myEvent 

and the template for the popover is:
(pls note that I have replaced < and > with | as otherwise it gets formatted as html page)

<ion-grid class="popover-page">
      <img src="img/a.jpg">
      <img src="img/b.jpg">
      <img src="img/c.jpg">
      <img src="img/d.jpg">

Appreciate any help.


Would you be able to recreate this in a plunkr?

Also, you can format your code between three `, three at the top and three at the bottom.


Hey Angelo, two ways.

  1. override the SCSS variables;

$popover-md-width: 320px; $popover-ios-width: 320px; $popover-wp-width: 320px;

or 2. give your popover a class:

let popover = this.popover.create(ContactPopover, {}, {cssClass: 'contact-popover'})

and then style the .popover-content:

.contact-popover .popover-content{ width: 320px; }

Ionic automatically calculates the correct position for your custom width popover.


Hi Mayteio this has to be the answer, but I can’t work out where to put your suggestions. I have generated a page called GoHomePage, which makes me file called go-home.scss that only has

page-go-home {

I call it with this:

let popover = this.popoverCtrl.create(GoHomePage, {}, {cssClass: 'page-go-home'});

Now I can style individual elements in the template file, so I figure the reference in call is correct, but nothing I do will let me change the size or position of the popover itself. If you have any further suggestions I’d be most grateful.

Here is my template:

    <ion-title>Start Again?</ion-title>
<ion-content padding>
  <ion-list class="homelist">
    <ion-list-header>Really Start Again?</ion-list-header>
      <button ion-button color="active" (click)="close('yes')"><ion-icon name="checkmark-circle"></ion-icon>Yes</button>
      <button ion-button color="danger" (click)="close('no')"><ion-icon name="close-circle"></ion-icon>No</button>

Worked out the first part. See this page https://ionicframework.com/docs/v2/theming/overriding-ionic-variables/

Add new variables, not just the ones already in the default file.

Hi, I tried to pass the cssClass but it doesn’t take any effect, any idea?

I found that the cssClass should defined in the app.scss, n it works like charm!!

1 Like

Do not add your css between

page-go-home {

Because the popover is generated outside the selected page. When you add is like this it should work, got the same thing myself too.

So the CSS would look like this.

page-go-home {
.contact-popover .popover-content{ width: 320px; }


This worked. for me. thanks a lot.
cssClass should defined in the app.scss.