Creating a Pinterest Layout with Ionic [v4]


If you want to create a Pinterest like layout with Ionic 4, you will encounter problems with the default implementation of the grid and a standard column based layout.

In this Quick Win we will implement a real Pinterest grid layout with Ionic using some custom CSS, media queries and even an official animation (borrowed from the Pinterest page).


We will also use a cool API called the Lorem Ipsum for photos so we got some real images for our Pinterest feed!

Getting Started

Because we’ll just build upon basic HTML and CSS stuff we simple need a blank app for testing:

Since we also want to make HTTP request to get some images we also need to add the according module as always to our app/app.module.ts like:

That’s all of the preparation!

Implementing the Basic Pinterest Grid

We start by loading images from the API, and we will use pagination which works great with an infinite scroll component.

The only tricking thing is that the information about the next page or result count and number of pages is not inside the body, but passed inside a field of the response header. Therefore, we have to observe the full response of our HTTP GET request and then extract the according field which is called “next”.

Besides that we only fill our array of images or append images if there are already elements in it, so here we go with our app/home/

Now we come to the actual Pinterest styling. The problem is, the standard Ionic grid won’t deliver the result you want to see, therefore we have to use our own markup with additional CSS to make things work.

So we can create an iteration based on our imageList and simply use some div elements on which we add styling in the next step. We’ll also add a button in it – and we only want to show it once we hover over a pin!

Of course this is not really working on a mobile device, but chances are you also build for the web and then it’s a great animation and visual appealing behaviour.

At the bottom of the view we put our infinite loading component that will simply trigger our loadImages function now with an event that will be completed once we are done loading images.

Go ahead with the app/home/ and change it to:

This will now look like a bunch of garbage in your preview, because we haven’t added any CSS!

The most important part here is right at the beginning, perhaps add the rules one by one to see what’s going on and how they affect your app.

We use the column-count property do define that our view should be divided in different columns, just like you would do inside the standard Ionic grid row/column layout. But we take things a step further and also apply media queries to our rule in order to increase the column count on different screen sizes.

On a small screen we would have 2 columns, while at the biggest breakpoint we have even 5 columns!

Besides that we have some styling to make our collection-item pin more like a real Pinterest pin, and finally additional CSS for hovering over our Pins. Actually the animation is from the Pinterest page, I take no credit in that animation!

But what I added is additional styling for our button – by default it won’t be displayed, but in the hover state we will make it visible.

Now change your app/home/ and add all the rules:

Now you can scroll through your Pinterest feed and hover all the elements. Note that the images returned from the API are pretty big so don’t worry if the loading takes some time!

One final tip: In order to debug things like the hover state more easily you can simply select the element in your debugging view and directly toggle the hover state to see how it looks then:

That’s actually a lot better then trying to hover and immediately afterwards select the element which is not really working. Not that I have tried of course…


The Pinterest layout in Ionic can be achieved with basic HTML and CSS, but it’s not working out of the box with the standard Grid.

However, the presented approach should give you a good starting point for your next image powered app!

You can also watch a video version of this Quick Win below.