Grid question


Hi there,

Is it possible to do something like this with the grid?

If so, how you would do it?



In the HTML:


<ion-content class="grid-full">

    <ion-col class="cell-1">
    <ion-col class="cell-2">
    <ion-col class="cell-3">
    <ion-col class="cell-4">
    <ion-col class="cell-5">
    <ion-col class="cell-6">


In the CSS:

.grid-full ion-row {
  height: 100%;
  padding: 0;
  flex-wrap: wrap;

.grid-full ion-col {
  flex: 0 0 50%;
  max-width: 50%;
  text-align: center;
  padding: 10px 5px;

.cell-1 {
  background-color: #C5DCFC;
.cell-2 {
  background-color: #262B69;
.cell-3 {
  background-color: #A0C5FA;
.cell-4 {
  background-color: #B3D0FC;
.cell-5 {
  background-color: #73A7F9;
.cell-6 {
  background-color: #8CB9FA;

Note: you could also add width-50 as an attribute to each ion-col but I just did it in the CSS because it applies to all of them. We could always add some attributes to make this easier.

You’ll have to tweak the CSS to add the images and center them vertically, but this is a good starting point. :smile:


If you don’t mind that the rows don’t get pushed out, but get equally smaller,
here is my try


Very nice, thanks for your help @brandyshea and @YayO


Hi again,

I am sure it is doable, but I don’t have the knowledge to do it yet.

Here the current code

    <ion-col *ngFor="#menu of menus" class="cell-0" (click)="menuSelected(menu)">
      <ion-icon [name]="menu.icon"></ion-icon>
      <ion-label>{{ }}</ion-label>

Like you can see, it will create all my cells with different icons and labels, but I don’t know how to increment the number of the “class”. How can I change “cell-0” to something like “cell-i”? Unless there is a way to apply the cell background color with a different way? It will be nice if it could be something like <ion-col [color]="menu.cellColor">



There’s some ways like:

<ion-col *ngFor='#menu of menus; #i = index' class='cell-{{i}}'> // Not tested, i think it should work

But i would recommend you just add the class to the menu item in the array and use it with ngClass:

<ion-col *ngFor='#menu of menus' [ngClass]='menu.backgroundColor'>


You should be able to use ngClass with index similar to the way @luchillo17 said. We’re doing something similar in tabs:

Like I said in another reply though we need to discuss adding the color attribute to multiple components. :smile:


@luchillo17, the first one is working and of course, the second one too.



@brandyshea, I agree, the color attribut should be everywhere! :slight_smile:


Glad it worked, tough the first one i suggested looks kind of like a hacky workaround.


Thanks Brandy, this code is working fine on Ionic v3, you are pretty and smart.



Want to align the text vertically center, could you update pls