Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions docs/api/gallery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
title: "ion-gallery"
---

import Props from '@ionic-internal/component-api/v9/gallery/props.md';
import Events from '@ionic-internal/component-api/v9/gallery/events.md';
import Methods from '@ionic-internal/component-api/v9/gallery/methods.md';
import Parts from '@ionic-internal/component-api/v9/gallery/parts.md';
import CustomProps from '@ionic-internal/component-api/v9/gallery/custom-props.mdx';
import Slots from '@ionic-internal/component-api/v9/gallery/slots.md';

<head>
<title>ion-gallery: Responsive Uniform and Masonry Gallery Layouts</title>
<meta
name="description"
content="The gallery arranges images, cards, and other content in responsive uniform or masonry layouts with configurable column counts and masonry ordering modes."
/>
</head>

import EncapsulationPill from '@components/page/api/EncapsulationPill';

<EncapsulationPill type="shadow" />

The gallery arranges images, cards, and other content in a responsive grid. It supports uniform and masonry layouts, configurable column counts (fixed or breakpoint-based), and multiple masonry ordering modes.

## Basic Usage

import Basic from '@site/static/usage/v9/gallery/basic/index.md';

<Basic />

## Uniform

Uniform is the default layout. It creates a consistent grid where items appear at the same visual size with a `1 / 1` aspect ratio. This layout is ideal when visual alignment is more important than preserving each item's natural height.

import Uniform from '@site/static/usage/v9/gallery/uniform/index.md';

<Uniform />

## Masonry

Masonry preserves each item's natural height and stacks items vertically within each column, creating a staggered layout with minimal gaps. Masonry supports two ordering modes: sequential and best fit.

:::important
Avoid adding margin to top-level items in a masonry layout, as it can cause incorrect item placement. To add spacing, wrap the content in a child element and apply margin to that wrapper instead.
:::

### Sequential

Sequential is the default masonry ordering mode. Items are placed in DOM order, filling columns from left to right.

import MasonrySequential from '@site/static/usage/v9/gallery/masonry-sequential/index.md';

<MasonrySequential />

### Best Fit

Best fit places each item in the column with the most available space, helping balance column heights.

import MasonryBestFit from '@site/static/usage/v9/gallery/masonry-best-fit/index.md';

<MasonryBestFit />

### Images

In masonry layouts, top-level `img` elements are given default styles to ensure consistent rendering. These styles make images fill their container while preserving their aspect ratio and keeping them centered.

:::note
Images wrapped in other elements (for example, inside a `figure`) do not inherit these defaults. Apply the same styles to the nested `img` if you want matching behavior.
:::

import Images from '@site/static/usage/v9/gallery/images/index.md';

<Images />

## Columns

Columns can be configured with the `columns` property using either a single number for a fixed column count, or a breakpoint map to change columns across screen sizes.

If no value is provided, or if an invalid value is used, the gallery falls back to its default responsive column behavior. The default column counts by breakpoint are:

| Breakpoint | Min Width | Default Columns |
| --- | --- | ---|
| `xs` | `0` | `2` |
| `sm` | `576px` | `3` |
| `md` | `768px` | `4` |
| `lg` | `992px` | `6` |
| `xl` | `1200px` | `8` |
| `xxl` | `1400px` | `10` |

import Columns from '@site/static/usage/v9/gallery/columns/index.md';

<Columns />

## Interfaces

### GalleryBreakpointColumns

```typescript
interface GalleryBreakpointColumns {
xs?: string | number;
sm?: string | number;
md?: string | number;
lg?: string | number;
xl?: string | number;
xxl?: string | number;
}
```

## Types

### GalleryColumns

```typescript
type GalleryColumns = GalleryBreakpointColumns | string | number;
```

## Properties
<Props />

## Events
<Events />

## Methods
<Methods />

## CSS Shadow Parts
<Parts />

## CSS Custom Properties
<CustomProps />

## Slots
<Slots />
6 changes: 3 additions & 3 deletions docs/components.md
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to add this under "Grids" because otherwise we would need to redo the component page to either add a new image for a top-level Gallery section or to add something like "Layout" which would reorder a few of them. I can change this if we want to categorize this differently.

Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Ionic apps are made of high-level building blocks called Components, which allow
<p>Floating action buttons are circular buttons that perform a primary action on a screen.</p>
</DocsCard>

<DocsCard header="Grid" href="api/grid" icon="/icons/component-grid-icon.png">
<p>The grid is a powerful mobile-first system for building custom layouts.</p>
<DocsCard header="Grids" href="api/grid" icon="/icons/component-grid-icon.png">
<p>A collection of layout components for building responsive grids and image layouts.</p>
</DocsCard>

<DocsCard header="Icons" href="api/icon" icon="/icons/component-icons-icon.png">
Expand All @@ -87,7 +87,7 @@ Ionic apps are made of high-level building blocks called Components, which allow
</DocsCard>

<DocsCard header="Inputs" href="api/input" icon="/icons/component-input-icon.png">
<p>Inputs provides a way for users to enter data in your app.</p>
<p>Inputs provide a way for users to enter data in your app.</p>
</DocsCard>

<DocsCard header="Item" href="api/item" img="/icons/feature-component-item-icon.png">
Expand Down
2 changes: 1 addition & 1 deletion plugins/docusaurus-plugin-ionic-component-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = function (context, options) {
await generateMarkdownForVersion(version, npmTag, context.i18n.currentLocale, false);
}

let npmTag = 'latest';
let npmTag = '8.8.6-dev.11777668103.132817bd';
if (currentVersion.banner === 'unreleased') {
npmTag = 'next';
} else if (currentVersion.path !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ module.exports = {
},
{
type: 'category',
label: 'Grid',
label: 'Grids',
collapsed: false,
items: ['api/grid', 'api/col', 'api/row'],
items: ['api/grid', 'api/col', 'api/row', 'api/gallery'],
},
{
type: 'category',
Expand Down
14 changes: 7 additions & 7 deletions static/code/stackblitz/v9/angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/code/stackblitz/v9/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@angular/platform-browser": "^20.0.0",
"@angular/platform-browser-dynamic": "^20.0.0",
"@angular/router": "^20.0.0",
"@ionic/angular": "8.7.11",
"@ionic/core": "8.7.11",
"@ionic/angular": "8.8.6-dev.11777668103.132817bd",
"@ionic/core": "8.8.6-dev.11777668103.132817bd",
"ionicons": "8.0.13",
"rxjs": "^7.8.1",
"tslib": "^2.5.0",
Expand Down
6 changes: 3 additions & 3 deletions static/code/stackblitz/v9/html/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/code/stackblitz/v9/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "vite preview"
},
"dependencies": {
"@ionic/core": "8.7.11",
"@ionic/core": "8.8.6-dev.11777668103.132817bd",
"ionicons": "8.0.13"
},
"devDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions static/code/stackblitz/v9/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/code/stackblitz/v9/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ionic/react": "8.7.11",
"@ionic/react-router": "8.7.11",
"@ionic/react": "8.8.6-dev.11777668103.132817bd",
"@ionic/react-router": "8.8.6-dev.11777668103.132817bd",
"@types/node": "^24.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
Expand Down
20 changes: 10 additions & 10 deletions static/code/stackblitz/v9/vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/code/stackblitz/v9/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@ionic/vue": "8.7.11",
"@ionic/vue-router": "8.7.11",
"@ionic/vue": "8.8.6-dev.11777668103.132817bd",
"@ionic/vue-router": "8.8.6-dev.11777668103.132817bd",
"vue": "^3.2.25",
"vue-router": "4.6.3"
},
Expand Down
Binary file added static/img/demos/gallery/01.png
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this location of images used by the demos but other demos use this as well so I followed the existing structure.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/demos/gallery/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading