Home / Blog / How to create an Album gallery viewer screen | Ionic Design Kit

How to create an Album gallery viewer screen | Ionic Design Kit

Ionic Design Kit, built on a design base of Ionic Framework components, simplifies app development by providing designers with a range of pre-made elements. Designers can effortlessly pick and place elements, eliminating the need to create components from scratch. For developers, this means no complex coding – all components are sourced from the Ionic Framework. The result is a speedy, efficient, and collaborative process, making the Ionic Design Kit essential for both designers and developers.

The Album Gallery Screen has become an essential feature for mobile applications, particularly those focused on media and photography. This screen allows users to seamlessly browse, organize, and interact with their photo collections, offering an intuitive user experience. By providing a clear, organized display of images, the Album Gallery Screen facilitates easy navigation and management of large photo libraries, making it a critical component for any app aiming to offer a superior media viewing or sharing experience.

This article offers a comprehensive guide, equipping designers and developers to seamlessly integrate a user-centric Gallery screen into their applications. This effortless integration is made possible by leveraging design components from the Ionic Kit, built on the robust foundation of the extensive library within the Ionic framework.

1. Install Ionic CLI with the command

Creating a project with the Ionic CLI

npm i -g @ionic/cli

2. Create a new project

To create a new project, run the following command.

ionic start gallery-screen blank --type=react

3. Get inside the project directory

cd gallery-screen

4. Create page Gallery.tsx inside src/pages and add code

import { IonPage } from '@ionic/react';

const Gallery: React.FC = () => {
  return (
    <IonPage></IonPage>
  );
};

export default Gallery;

Please make sure that you've added routing in src/App.tsx for the created page. All Ionic framework components that will be used below should be imported similarly to the IonPage component.

5. Add the header inside the page

For convenience, we will be using the layout structure recommended by Ionic for our screens. This allows us to add header code and content inside the <IonPage></IonPage>.

<IonPage>
  <IonHeader>
    <IonToolbar>
    ...
    </IonToolbar>
  </IonHeader>
  <IonContent>
  ...
  </IonContent>
</IonPage>

6. Add buttons to the toolbar

Inside the IonToolbar component, add the IonButtons component and set the slot to start. This positions the button at the beginning of the toolbar.

<IonHeader>
  <IonToolbar>
    <IonButtons slot='start'>
    </IonButtons>
  </IonToolbar>
</IonHeader>

7. Include the Back button in the toolbar

Within the IonButtons component, include the IonBackButton component, setting the properties defaultHref='#' and text='' to create a back button that navigates back in the app's history upon being clicked.

<IonHeader>
  <IonToolbar>
    <IonButtons slot='start'>
      <IonBackButton defaultHref='#' text=''></IonBackButton>
    </IonButtons>
  </IonToolbar>
</IonHeader>

8. Place the title

After the IonButtons component, place the IonTitle with the text 'Favorites' to add a title for this page.

<IonHeader>
  <IonToolbar>
    <IonButtons slot='start'>
      <IonBackButton defaultHref='#' text=''></IonBackButton>
    </IonButtons>
    <IonTitle>Favorites</IonTitle>
  </IonToolbar>
</IonHeader>

9. Add the content

Following the IonHeader component, add the IonContent component and apply the ion-padding-top class to style the content within.

<IonHeader>
...
</IonHeader>
<IonContent className='ion-padding-top'>
</IonContent>

10. Add an item within the component

Inside the IonContent component, add the IonItem component with the property lines='none' to style the component.

<IonContent className='ion-padding-top'>
  <IonItem lines='none'>
  </IonItem>
</IonContent>

11. Place the label

Within the IonText add the IonLabel component with the text 'Shared albums'.

<IonItem lines='none'>
  <IonLabel>Shared albums</IonLabel>
</IonItem>

Add the IonRouterLink component with the properties href='#', color='medium' and set the text 'View all' inside.

<IonItem lines='none'>
  <IonLabel>Shared albums</IonLabel>
  <IonRouterLink href='#' color='medium'>View all</IonRouterLink>
</IonItem>

13. After the IonItem, add the IonCard component

<IonContent className='ion-padding-top'>
  ...
  <IonCard>
  </IonCard>
</IonContent>

14. Place the img inside the card

Inside the IonCard add the IonImg component with the property src={pic1}. Remember to import the required images before.

<IonCard>
  <IonImg src={pic1}></IonImg>
</IonCard>

15. Add the IonCardHeader component

<IonCard>
  <IonImg src={pic1}></IonImg>
  <IonCardHeader>
  </IonCardHeader>
</IonCard>

16. Place the Card title

Inside the IonCardHeader add the IonCardTitle component with the text 'Travel'.

<IonCard>
  <IonImg src={pic1}></IonImg>
  <IonCardHeader>
    <IonCardTitle>Travel</IonCardTitle>
  </IonCardHeader>
</IonCard>

17. Add the content

After the IonCardHeader, add the IonCardContent with the text 'Perfect places to travel'.

<IonCard>
  <IonImg src={pic1}></IonImg>
  <IonCardHeader>
    <IonCardTitle>Travel</IonCardTitle>
  </IonCardHeader>
  <IonCardContent>Perfect places to travel</IonCardContent>
</IonCard>

18. Add another IonCard component

<IonContent className='ion-padding-top'>
  ...
  <IonCard>
  </IonCard>
</IonContent>

19. Repeat step 14 and set the property src={pic2}

<IonCard>
  <IonImg src={pic2}></IonImg>
</IonCard>

20. Repeat step 15

21. Repeat step 16

Set the text 'Flower Festival' inside the IonCardTitle.

22. Repeat step 17

Set the text 'Best moments of the festival' inside the IonCardContent.

Thank you for joining us on this exciting journey thus far. Stay tuned for more guides in our comprehensive series, where we'll not only delve into various aspects of mobile app development but also showcase how the Ionic Kit can be your game-changer.

Looking for Ionic kit for you platform?
Ionic Sketch
Ionic Figma
Ionic XD