{"id":1283,"date":"2016-08-31T13:28:48","date_gmt":"2016-08-31T13:28:48","guid":{"rendered":"https:\/\/ionic.io\/blog\/?p=1283"},"modified":"2016-11-04T15:09:13","modified_gmt":"2016-11-04T15:09:13","slug":"layout-the-cool-way-using-the-ionic-2-grid-component","status":"publish","type":"post","link":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component","title":{"rendered":"Layout the Cool Way: Using the Ionic 2 Grid Component"},"content":{"rendered":"<p>One of the first things a lot of developers love about Ionic is that it makes the tedious task of building basic app components that Just Look Good much easier. But did you know Ionic also has a grid component that makes layout easy? This is awesome because, well, CSS is a pain, and why deal with it if you don&#8217;t have to?<\/p>\n<p>Take the photo gallery example app we built <a href=\"https:\/\/ionic.io\/blog\/ionic-native-accessing-ios-photos-and-android-gallery-part-i\/\">in a previous blog post<\/a>. This app uses Ionic Native&#8217;s <a href=\"http:\/\/ionicframework.com\/docs\/v2\/native\/image-picker\/\">Image Picker plugin<\/a>, which allows the user to select multiple photos from their native photo app, then displays the selected photos in a nice gallery layout, like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"534\" data-src=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1556-2.png\" alt=\"gallery view\" class=\"aligncenter size-full wp-image-1375 lazyload\" data-srcset=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1556-2.png 300w, https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1556-2-169x300.png 169w\" data-sizes=\"auto, (max-width: 300px) 100vw, 300px\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" style=\"--smush-placeholder-width: 300px; --smush-placeholder-aspect-ratio: 300\/534;\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"534\" src=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1556-2.png\" alt=\"gallery view\" class=\"aligncenter size-full wp-image-1375\" srcset=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1556-2.png 300w, https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1556-2-169x300.png 169w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/noscript><\/p>\n<p>Sure, this is just a relatively simple two-column layout, but even if you&#8217;re a seasoned CSS master, you&#8217;d probably rather not deal with writing the styles for from scratch. And why would you? As developers, we excel at <s>taking shortcuts<\/s> implementing great tooling to help speed up our jobs, and in this case the good news is that Ionic 2, sprinkled with a little Angular 2, makes this a pretty simple, declarative process.<br \/>\n<!--more--><\/p>\n<h3>Getting Set Up<\/h3>\n<p>Want to follow along? Start by doing the following:<\/p>\n<ol>\n<li>Download the <a href=\"https:\/\/github.com\/amuramoto\/ionic-imagepicker-sample\/tree\/grid-starter\">starter project<\/a> from GitHub.<\/li>\n<li>Run <code>npm install<\/code> in the project directory.<\/li>\n<li>Run <code>ionic plugin add cordova-plugin-image-picker<\/code> in the project directory to install the Ionic Native Image Picker plugin.<\/li>\n<\/ol>\n<p>Since this example uses the photo picker app from a previous post, you&#8217;ll also need to run the app on a device with the usual <code>ionic run ios<\/code>, <code>ionic run android<\/code>, <a href=\"http:\/\/view.ionic.io\/\">Ionic View<\/a>, or <a href=\"http:\/\/docs.ionic.io\/docs\/package-overview\">Ionic Package<\/a>.<\/p>\n<p>Now, we can get straight to it. The only additional thing we&#8217;re going to implement in this app is the grid component, so we don&#8217;t need to import any additional dependencies into our project.<\/p>\n<h3>Building the Grid<\/h3>\n<p>To start, we drop the following into <code>&lt;ion-content&gt;<\/code> in our <code>app\/pages\/gallery\/gallery.html<\/code> template file:<\/p>\n<pre><code>&lt;ion-grid&gt;\n  &lt;ion-row *ngFor=&quot;let row of grid&quot;&gt;\n  &lt;\/ion-row&gt;\n&lt;\/ion-grid&gt;\n<\/code><\/pre>\n<p>Similar to the popular Bootstrap UI framework for web development, Ionic&#8217;s grid component handles the layout of our app view as a set of columns and rows. In this case, <code>&lt;ion-grid&gt;<\/code> is an Ionic 2 component available out of the box that places the container for a grid layout in the DOM. Inside the grid, we have a series of rows declared with the <code>&lt;ion-row&gt;<\/code> component.<\/p>\n<p>For this view, we want multiple rows, so we use Angular 2&#8217;s structural <code>*ngFor<\/code> directive, which will insert an <code>&lt;ion-row&gt;<\/code> for each value in an iterable we provide. In this case, the iterable is a <code>grid<\/code> array:<\/p>\n<p><code>&lt;ion-row *ngFor=&quot;let row of grid&quot;&gt;<\/code><\/p>\n<p>To make this work, we need to define the array in <code>app\/pages\/gallery\/gallery.ts<\/code>. In this file, you&#8217;ll see that I&#8217;ve already included the code needed to get the array of file URIs that are passed in from the previous view by using Ionic&#8217;s <code>NavParams.get()<\/code>:<\/p>\n<pre><code>images: Array&lt;string&gt;;  \n\nconstructor(public navCtrl: NavController, public navParams: NavParams) {\n  this.images = this.navParams.get(&#039;images&#039;); \/\/get file URIs\n}\n<\/code><\/pre>\n<p>Conceptually, what we want to do next is declare an array where each index represents a row that contains a nested array of the file URIs for the images we want to display in that row. That sounds a little confusing, so think of it this way: We&#8217;re just modeling our array to look the way we want the final grid to look&#8211;the outer array models the grid, while the inner array models rows in the grid. The grid array will look like this:<\/p>\n<p><code>[[file_uri, file_uri], [file_uri, file_uri], [file_uri, file_uri], ...]<\/code><\/p>\n<p>To do this, we start by declaring a <code>grid<\/code> array in <code>gallery.ts<\/code> above the class constructor. Notice how our TypeScript declaration is declaring an array (our grid) that contains nested arrays of strings (our rows):<\/p>\n<pre><code>images: Array&lt;string&gt;;  \ngrid: Array&lt;Array&lt;string&gt;&gt;; \/\/array of arrays\n<\/code><\/pre>\n<p>Next, in our constructor, we define the size of the array to be equal to the number of rows we want in our grid. Since the user can choose an arbitrary number of images, we need to do some simple math to get the number of rows we need:<\/p>\n<pre><code>constructor(public navCtrl: NavController, public navParams: NavParams) {\n  this.images = this.navParams.get(&#039;images&#039;);\n  this.grid = Array(Math.ceil(this.images.length\/2)); \/\/MATHS!\n}\n<\/code><\/pre>\n<p>We want two images per row in our grid, so all we&#8217;ve done is divide the number of file URIs in <code>this.images<\/code> by 2, then used JavaScript&#8217;s <code>Math.ceil()<\/code> operator to make sure we round up in the event that the number of photos isn&#8217;t even. So, for example, if the user selects seven photos, we create four rows.<\/p>\n<p>Then, we just need to insert two images per row. We&#8217;ll do this as soon as the <code>GalleryPage<\/code> component is ready to load, by running our logic in <code>IonViewLoaded()<\/code>. For those not familiar with <a href=\"http:\/\/ionicframework.com\/docs\/v2\/api\/components\/nav\/NavController\/#lifecycle-events\">lifecycle events in Ionic 2<\/a>, <code>ionViewLoaded()<\/code> is called when the component, in this case the <code>Home<\/code> page, first loads. We call our logic here, so that it runs before the view appears.<\/p>\n<pre><code>ionViewLoaded() {\n\n  let rowNum = 0; \/\/counter to iterate over the rows in the grid\n\n  for (let i = 0; i &lt; this.images.length; i+=2) { \/\/iterate images\n\n    this.grid[rowNum] = Array(2); \/\/declare two elements per row\n\n    if (this.images[i]) { \/\/check file URI exists\n      this.grid[rowNum][0] = this.images[i] \/\/insert image\n    }\n\n    if (this.images[i+1]) { \/\/repeat for the second image\n      this.grid[rowNum][1] = this.images[i+1]\n    }\n\n    rowNum++; \/\/go on to the next row\n  }\n\n}\n<\/code><\/pre>\n<p>We now have an array that models our grid, so all we have to do is add columns to the rows in our template. For this, we again use <code>*ngFor<\/code>, this time to add an <code>&lt;ion-col&gt;<\/code> for each of the photos in each row. Here, the <code>*ngFor<\/code> in our <code>&lt;ion-row&gt;<\/code> iterates over each row in the <code>grid<\/code> array; then, the <code>*ngFor<\/code> in each <code>&lt;ion-col&gt;<\/code> iterates over the file URI strings in that row and sets each as the <code>src<\/code> attribute for an <code>&lt;img&gt;<\/code> tag. We&#8217;ll also use the built-in <code>width-50<\/code> attribute of <code>&lt;ion-col&gt;<\/code>. This tells Ionic to automatically size the column to be 50% the width of the grid, taking into account gutter width (the fancy spacing between columns):<\/p>\n<pre><code>&lt;ion-grid&gt;\n  &lt;ion-row *ngFor=&quot;let row of grid&quot;&gt;\n    &lt;ion-col width-50 *ngFor=&quot;let file_uri of row&quot;&gt;\n      &lt;img [src]=&quot;file_uri&quot;&gt;\n    &lt;\/ion-col&gt;\n  &lt;\/ion-row&gt;\n&lt;\/ion-grid&gt;\n<\/code><\/pre>\n<p>And there we go. A beautiful grid that will render as expected across iOS, Android, and Windows Phone, without a drop of CSS.<\/p>\n<h3>Is That All it Does?<\/h3>\n<p>Not by a long shot, friend!<\/p>\n<p>OK, declaratively building a two-column, symmetrical grid layout for an image gallery is neat and all, but it&#8217;s pretty basic, all things considered. Not to worry! The grid, row and column components in Ionic 2 support a variety of attributes to help you build complex layouts that render consistently across platforms and devices, including specialized attributes for declaring offsets, widths, vertical alignment, and text wrapping.<\/p>\n<p>For example, here&#8217;s our same gallery made inmo a simple profile page:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"534\" data-src=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1559-2.png\" alt=\"profile view\" class=\"aligncenter size-full wp-image-1376 lazyload\" data-srcset=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1559-2.png 300w, https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1559-2-169x300.png 169w\" data-sizes=\"auto, (max-width: 300px) 100vw, 300px\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" style=\"--smush-placeholder-width: 300px; --smush-placeholder-aspect-ratio: 300\/534;\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"534\" src=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1559-2.png\" alt=\"profile view\" class=\"aligncenter size-full wp-image-1376\" srcset=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1559-2.png 300w, https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1559-2-169x300.png 169w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/noscript><\/p>\n<p>And just to show you how much is actually going on in this layout, here&#8217;s a view of the grid and grid attributes that actually handles the layout, with rows in red and columns in green:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"534\" data-src=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1560-2.png\" alt=\"grid layout\" class=\"aligncenter size-full wp-image-1377 lazyload\" data-srcset=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1560-2.png 300w, https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1560-2-169x300.png 169w\" data-sizes=\"auto, (max-width: 300px) 100vw, 300px\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" style=\"--smush-placeholder-width: 300px; --smush-placeholder-aspect-ratio: 300\/534;\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"534\" src=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1560-2.png\" alt=\"grid layout\" class=\"aligncenter size-full wp-image-1377\" srcset=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1560-2.png 300w, https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/IMG_1560-2-169x300.png 169w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/noscript><\/p>\n<p>That&#8217;s potentially a lot of CSS we would have had to write, and we get to handle it all declaratively, using grid attributes. That&#8217;s pretty swank, if you ask me.<\/p>\n<p>You might have noticed in this layout that the gallery is a single row. What gives? Just for the sake of example, I assigned the <code>wrap<\/code> attribute to the <code>&lt;ion-row&gt;<\/code> element, which causes all of the columns it contains to wrap. This completely removes the need for all that array building we did before, and simplifies our template for the image gallery to this:<\/p>\n<pre><code>&lt;ion-row wrap&gt;\n  &lt;ion-col width-33 *ngFor=&quot;let file_uri of images&quot;&gt;\n  &lt;img [src]=&quot;file_uri&quot;&gt;\n  &lt;\/ion-col&gt;\n&lt;\/ion-row&gt;\n<\/code><\/pre>\n<p>So, why didn&#8217;t we take the easy route when we built the two-column gallery? We could have, but that wouldn&#8217;t have been nearly as much fun as working with nested arrays!<\/p>\n<p>All kidding aside, the point is that there are almost always multiple ways to accomplish the same result, especially when it comes to building the layout of your app. Despite being simple to use, Ionic&#8217;s grid component provides a lot of flexibility, so give it a shot. If you&#8217;ve never worked with a grid layout before, you might be surprised at just how much of a headache it can save you in the long run.<\/p>\n<p>For more information on the grid component, check out the <a href=\"http:\/\/ionicframework.com\/docs\/v2\/components\/#grid\">Ionic 2 Grid docs<\/a>, and in case you want to see the finished Image Picker sample app in all its gridded glory, you can download or fork it on <a href=\"https:\/\/github.com\/amuramoto\/ionic-imagepicker-sample\">GitHub<\/a>. The starter for this project is available in the <a href=\"https:\/\/github.com\/amuramoto\/ionic-imagepicker-sample\/tree\/grid-starter\">&#8216;grid-starter&#8217; branch<\/a>, and the profile view is available in the <a href=\"https:\/\/github.com\/amuramoto\/ionic-imagepicker-sample\/tree\/grid-profile\">&#8216;grid-profile&#8217; branch<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the first things a lot of developers love about Ionic is that it makes the tedious task of building basic app components that Just Look Good much easier. But did you know Ionic also has a grid component that makes layout easy? This is awesome because, well, CSS is a pain, and why [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":1288,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"publish_to_discourse":"","publish_post_category":"","wpdc_auto_publish_overridden":"","wpdc_topic_tags":"","wpdc_pin_topic":"","wpdc_pin_until":"","discourse_post_id":"","discourse_permalink":"","wpdc_publishing_response":"","wpdc_publishing_error":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[23,13,25],"class_list":["post-1283","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all","tag-framework","tag-ionic-2","tag-tutorials"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v23.0 (Yoast SEO v23.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Layout the Cool Way: Using the Ionic 2 Grid Component - Ionic Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Layout the Cool Way: Using the Ionic 2 Grid Component\" \/>\n<meta property=\"og:description\" content=\"One of the first things a lot of developers love about Ionic is that it makes the tedious task of building basic app components that Just Look Good much easier. But did you know Ionic also has a grid component that makes layout easy? This is awesome because, well, CSS is a pain, and why [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component\" \/>\n<meta property=\"og:site_name\" content=\"Ionic Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-31T13:28:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-11-04T15:09:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"250\" \/>\n\t<meta property=\"og:image:height\" content=\"445\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alex Muramoto\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@alexmuramoto\" \/>\n<meta name=\"twitter:site\" content=\"@ionicframework\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alex Muramoto\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#article\",\"isPartOf\":{\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component\"},\"author\":{\"name\":\"Alex Muramoto\",\"@id\":\"https:\/\/ionic.io\/blog\/#\/schema\/person\/c5087ed0d4175ef63cbc3aca6c41bcc7\"},\"headline\":\"Layout the Cool Way: Using the Ionic 2 Grid Component\",\"datePublished\":\"2016-08-31T13:28:48+00:00\",\"dateModified\":\"2016-11-04T15:09:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component\"},\"wordCount\":1260,\"commentCount\":11,\"publisher\":{\"@id\":\"https:\/\/ionic.io\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg\",\"keywords\":[\"Framework\",\"Ionic 2\",\"Tutorials\"],\"articleSection\":[\"All\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component\",\"url\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component\",\"name\":\"Layout the Cool Way: Using the Ionic 2 Grid Component - Ionic Blog\",\"isPartOf\":{\"@id\":\"https:\/\/ionic.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg\",\"datePublished\":\"2016-08-31T13:28:48+00:00\",\"dateModified\":\"2016-11-04T15:09:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage\",\"url\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg\",\"contentUrl\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg\",\"width\":250,\"height\":445},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ionic.io\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Layout the Cool Way: Using the Ionic 2 Grid Component\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ionic.io\/blog\/#website\",\"url\":\"https:\/\/ionic.io\/blog\/\",\"name\":\"ionic.io\/blog\",\"description\":\"Build amazing native and progressive web apps with the web\",\"publisher\":{\"@id\":\"https:\/\/ionic.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ionic.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/ionic.io\/blog\/#organization\",\"name\":\"Ionic\",\"url\":\"https:\/\/ionic.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ionic.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2020\/10\/white-on-color.png\",\"contentUrl\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2020\/10\/white-on-color.png\",\"width\":1920,\"height\":854,\"caption\":\"Ionic\"},\"image\":{\"@id\":\"https:\/\/ionic.io\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/ionicframework\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/ionic.io\/blog\/#\/schema\/person\/c5087ed0d4175ef63cbc3aca6c41bcc7\",\"name\":\"Alex Muramoto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ionic.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/alex-lg-150x150.jpg\",\"contentUrl\":\"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/alex-lg-150x150.jpg\",\"caption\":\"Alex Muramoto\"},\"sameAs\":[\"https:\/\/x.com\/alexmuramoto\"],\"url\":\"https:\/\/ionic.io\/blog\/author\/alex\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Layout the Cool Way: Using the Ionic 2 Grid Component - Ionic Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component","og_locale":"en_US","og_type":"article","og_title":"Layout the Cool Way: Using the Ionic 2 Grid Component","og_description":"One of the first things a lot of developers love about Ionic is that it makes the tedious task of building basic app components that Just Look Good much easier. But did you know Ionic also has a grid component that makes layout easy? This is awesome because, well, CSS is a pain, and why [&hellip;]","og_url":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component","og_site_name":"Ionic Blog","article_published_time":"2016-08-31T13:28:48+00:00","article_modified_time":"2016-11-04T15:09:13+00:00","og_image":[{"width":250,"height":445,"url":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg","type":"image\/jpeg"}],"author":"Alex Muramoto","twitter_card":"summary_large_image","twitter_creator":"@alexmuramoto","twitter_site":"@ionicframework","twitter_misc":{"Written by":"Alex Muramoto","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#article","isPartOf":{"@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component"},"author":{"name":"Alex Muramoto","@id":"https:\/\/ionic.io\/blog\/#\/schema\/person\/c5087ed0d4175ef63cbc3aca6c41bcc7"},"headline":"Layout the Cool Way: Using the Ionic 2 Grid Component","datePublished":"2016-08-31T13:28:48+00:00","dateModified":"2016-11-04T15:09:13+00:00","mainEntityOfPage":{"@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component"},"wordCount":1260,"commentCount":11,"publisher":{"@id":"https:\/\/ionic.io\/blog\/#organization"},"image":{"@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage"},"thumbnailUrl":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg","keywords":["Framework","Ionic 2","Tutorials"],"articleSection":["All"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component","url":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component","name":"Layout the Cool Way: Using the Ionic 2 Grid Component - Ionic Blog","isPartOf":{"@id":"https:\/\/ionic.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage"},"image":{"@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage"},"thumbnailUrl":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg","datePublished":"2016-08-31T13:28:48+00:00","dateModified":"2016-11-04T15:09:13+00:00","breadcrumb":{"@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#primaryimage","url":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg","contentUrl":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg","width":250,"height":445},{"@type":"BreadcrumbList","@id":"https:\/\/ionic.io\/blog\/layout-the-cool-way-using-the-ionic-2-grid-component#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ionic.io\/blog"},{"@type":"ListItem","position":2,"name":"Layout the Cool Way: Using the Ionic 2 Grid Component"}]},{"@type":"WebSite","@id":"https:\/\/ionic.io\/blog\/#website","url":"https:\/\/ionic.io\/blog\/","name":"ionic.io\/blog","description":"Build amazing native and progressive web apps with the web","publisher":{"@id":"https:\/\/ionic.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ionic.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ionic.io\/blog\/#organization","name":"Ionic","url":"https:\/\/ionic.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ionic.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2020\/10\/white-on-color.png","contentUrl":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2020\/10\/white-on-color.png","width":1920,"height":854,"caption":"Ionic"},"image":{"@id":"https:\/\/ionic.io\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/ionicframework"]},{"@type":"Person","@id":"https:\/\/ionic.io\/blog\/#\/schema\/person\/c5087ed0d4175ef63cbc3aca6c41bcc7","name":"Alex Muramoto","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ionic.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/alex-lg-150x150.jpg","contentUrl":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/alex-lg-150x150.jpg","caption":"Alex Muramoto"},"sameAs":["https:\/\/x.com\/alexmuramoto"],"url":"https:\/\/ionic.io\/blog\/author\/alex"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/ionic.io\/blog\/wp-content\/uploads\/2016\/08\/gridprofile.jpg","_links":{"self":[{"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/posts\/1283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/comments?post=1283"}],"version-history":[{"count":0,"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/posts\/1283\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/media\/1288"}],"wp:attachment":[{"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/media?parent=1283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/categories?post=1283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ionic.io\/blog\/wp-json\/wp\/v2\/tags?post=1283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}