Search code examples
javascriptreactjsionic-frameworktabsprogressive-web-apps

How to hide Tabs in on Mobile Web client with Ionic PWA app


Tabs are perfect to have inside of iOS and Android apps, however having tabs on mobile web clients are not ideal because of the phone's bottom navigation bar. An example is how Etsy and Amazon scrap the tabs in their mobile web clients.

How can tabs be hidden on an Ionic React application for the mobile web client?

I imagine this will involve wrapping some sort of function or hook around the tabs with the below code.

 <IonTabBar slot="bottom">
          <IonTabButton tab="tab1" href="/tab1">
            <IonIcon icon={home} />
            <IonLabel></IonLabel>
          </IonTabButton>
          <IonTabButton tab="tab2" href="/tab2">
            <IonIcon icon={cart} />
            <IonLabel></IonLabel>
          </IonTabButton>
          <IonTabButton tab="tab3" href="/tab3">
            <IonIcon icon={person} />
            <IonLabel></IonLabel>
          </IonTabButton>
          <IonTabButton tab="tab4" href="/tab4">
            <IonIcon icon={menuSharp} />
            <IonLabel></IonLabel>
          </IonTabButton>
        </IonTabBar>

Thank you for any unique insights or perspectives.


Solution

  • Set a global variable tied to isPlatform('mobileweb');

    And then hide the tab panel based on this value.

    https://ionicframework.com/docs/react/platform