Home / Blog / How to create a Feed screen

How to create a Feed screen

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 Feed Screen is a core feature in social media, news, and content-sharing applications. It provides users with a dynamic, scrollable interface where they can discover new posts, updates, or content from other users or sources. A well-designed Feed Screen encourages users to stay engaged, browse for longer periods, and interact with the content. Key features like infinite scrolling, interactive elements (like, comment, share), and personalized content are essential for creating a successful Feed Screen.

This guide will walk you through the steps to design and implement a Feed Screen using the Ionic Design Kit. By leveraging its pre-built components and the Ionic Framework, you can create an intuitive, responsive, and visually appealing Feed Screen that keeps users engaged.

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 feed blank --type=react

3. Get inside the project directory

cd feed

4. Create a Tab bar component

Use this instruction to create a Tab bar component.

5. Create a Feed page

Create page Feed.tsx inside src/pages and add code.

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

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

export default Feed;

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.

6. Select the layout structure

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

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

7. Put the title on top of the page

Place the IonTitle with the text 'Logotype' to add a title for this page.

<IonHeader>
    <IonToolbar>
        <IonTitle>
            Logotype
        </IonTitle>
    </IonToolbar>
</IonHeader>

8. Place the Like and Chat buttons

Inside the IonToolbar component, add an IonButtons component with the slot set to end, positioning the button at the ending of the toolbar. Also, add className='ion-padding-end' to provide padding at the end.

Within the IonButtons component, incorporate the IonButton with IonIcon component inside with slot property to icon-only, color to medium and icon to {heartOutline}.

Then incorporate one more IonButton with IonIcon component inside with slot property to icon-only, color to medium and icon to {chatbubbleEllipsesOutline}.

import { heartOutline, chatbubbleEllipsesOutline } from "ionicons/icons";
...
<IonHeader>
    <IonToolbar>
        <IonTitle>
            Logotype
        </IonTitle>
        <IonButtons slot='end' className='ion-padding-end'>
            <IonButton>
                <IonIcon slot='icon-only' icon={heartOutline} color='medium' />
            </IonButton>
            <IonButton>
                <IonIcon slot='icon-only' icon={chatbubbleEllipsesOutline} color='medium' />
            </IonButton>
        </IonButtons>
    </IonToolbar>
</IonHeader>

This concludes our work with IonHeader, and the following sections will cover working with IonContent.

9. Build a responsive avatar grid

Within IonContent, an IonGrid is used to structure the layout, which contains an IonRow to organize items horizontally and multiple IonCol elements, each representing a column for an avatar and label. The IonAvatar component displays circular images by wrapping an <img> tag, while the IonLabel component is used to show text beneath each avatar.

...
<IonContent>
    <br />
    <IonGrid>
        <IonRow>
            <IonCol>
                <IonAvatar>
                    <img src='avo-4.jpg' alt='avatar' />
                </IonAvatar>
                <IonLabel>
                    You
                </IonLabel>
            </IonCol>
            <IonCol>
                <IonAvatar>
                    <img src='avo-3.jpg' alt='avatar' />
                </IonAvatar>
                <IonLabel>
                    Miller
                </IonLabel>
            </IonCol>
            <IonCol>
                <IonAvatar>
                    <img src='avo-2.jpg' alt='avatar' />
                </IonAvatar>
                <IonLabel>
                    Jennifer
                </IonLabel>
            </IonCol>
            <IonCol>
                <IonAvatar>
                    <img src='avo-6.jpg' alt='avatar' />
                </IonAvatar>
                <IonLabel>
                    Linda
                </IonLabel>
            </IonCol>
            <IonCol>
                <IonAvatar>
                    <img src='avo-1.jpg' alt='avatar' />
                </IonAvatar>
                <IonLabel>
                    Brown
                </IonLabel>
            </IonCol>
            <IonCol>
                <IonAvatar>
                    <img src='avo-5.jpg' alt='avatar' />
                </IonAvatar>
                <IonLabel>
                    Michael
                </IonLabel>
            </IonCol>
        </IonRow>
    </IonGrid>
</IonContent>

10. Create a simple list item with avatar and details

Include an IonList component to structure your list. Within it, add an IonItem component to represent an individual list item. Use the slot='start' attribute on IonAvatar to align the avatar to the left, and insert an <img> tag inside to display the image. Then, use IonLabel to add descriptive text for the list item, organizing text like a name and timestamp with IonText for styling. Finally, include an IonIcon component with the slot='end' attribute to display an icon aligned to the right.

<IonContent>
...
    <IonList lines='none'>
        <IonItem className='ion-margin-top'>
            <IonAvatar slot='start'>
                <img src='avo-2.jpg' alt='avatar' />
            </IonAvatar>
            <IonLabel>
                <IonText>
                    Jennifer Johnson
                </IonText>
                <br />
                <IonText>
                    8 min ago
                </IonText>
            </IonLabel>
        <IonIcon slot='end' icon={ellipsisHorizontal} />
    </IonItem>
</IonContent>

11. Display an image in an IonicCard

To create a card with an image in Ionic, start by using the IonCard component to define the card structure. Inside the card, include an IonImg component to display the image, and specify the source of the image using the src attribute. This setup allows you to create a visually appealing card containing a single image.

<IonContent>
    ...
    <IonCard>
        <IonImg src='card-one.png' />
    </IonCard>
</IonContent>

12. Create an action bar with buttons

To design an action bar in Ionic, start with the IonItem component to serve as the container. Inside, use multiple IonButton components with the fill='clear' property for a minimalist style. Add icons to the buttons with IonIcon and specify their placement using the slot attribute, such as 'start'. Use color attributes to customize the appearance of each button. Place one button at the end using slot='end' for layout flexibility and add custom className. This code creates an interactive row with buttons for likes, comments, shares, and bookmarking.

<IonContent>
    ...
    <IonItem className='ion-padding-start'>
        <IonButton fill='clear'>
            <IonIcon slot='start' icon={heart} />
            78
        </IonButton>
        <IonButton fill='clear' color='medium'>
            <IonIcon slot='start' icon={chatbubbleOutline} />
            65
        </IonButton>
        <IonButton fill='clear' color='medium'>
            <IonIcon slot='start' icon={paperPlaneOutline} />
            5
        </IonButton>
        <IonButton fill='clear' color='medium' slot='end' className='end'>
            <IonIcon slot='start' icon={bookmarkOutline} />
        </IonButton>
    </IonItem>
</IonContent>

13. Display text

To display text use the IonItem component as the container. Inside it, add an IonText component for the main content, and style parts of the text with the color attribute to differentiate sections. Include a IonText element for the 'more' link and apply a darker color for emphasis. This setup creates a concise text preview.

<IonContent>
    ...
    <IonItem>
        <IonText color='medium'>
      Christmas preparations are in full swing. Have you already
      prepared gifts for your famil...
    <IonText color='dark'>more</IonText>
        </IonText>
    </IonItem>
</IonContent>

14. Create another feed item

Repeat steps 10 through 13 to add another feed item with different data.

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.

Are you prepared to elevate your Ionic experience? Explore the advantages of incorporating the Ionic Design Kit for intuitive designs and seamless development. May your coding journey be marked by continual innovation and triumphant achievements!

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