# Refactoring ion-navbar into custom component causing overlap

**URL:** <https://forum.ionicframework.com/t/refactoring-ion-navbar-into-custom-component-causing-overlap/126282>\
**Category:** ionic-v3\
**Created:** [March 29, 2018, 7:59am UTC](https://forum.ionicframework.com/t/refactoring-ion-navbar-into-custom-component-causing-overlap/126282 "2018-03-29T07:59:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bwhiting](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bwhiting/32/117866_2.png) [@bwhiting](https://forum.ionicframework.com/u/bwhiting)\
**Post date:** [March 29, 2018, 7:59am UTC](https://forum.ionicframework.com/t/refactoring-ion-navbar-into-custom-component-causing-overlap/126282/1 "2018-03-29T07:59:24Z")

</div>

I noticed I had a lot of repeated code and functionality in my ion-navbar, so I thought it might be a good idea to create a custom component to factor it out. For some reason, this is causing problems where now the header/navbar is overlapping the status bar. I could just factor out a smaller part of code instead, but I’d like to understand why this is causing a problem.

custom navbar component html

```auto
<ion-navbar>
  <button ion-button menuToggle>
    <ion-icon name="menu"></ion-icon>
  </button>
  <ion-title>{{ title }}</ion-title>
  <ion-buttons end class="desktop-buttons">
    <button ion-button (click)="signIn()">
      <div>
        <ion-icon name="person" padding-right></ion-icon>
        <span>Sign In</span>
      </div>
    </button>
  </ion-buttons>
</ion-navbar>

```

custom navbar ts

```auto
import { Component, Input } from '@angular/core';
import { ModalController, ToastController } from 'ionic-angular';
import { LoginModalPage } from '../../pages/login-modal/login-modal';

@Component({
  selector: 'custom-nav',
  templateUrl: 'custom-nav.html'
})
export class CustomNavComponent {
  @Input() title;

  constructor(
    private toastCtrl: ToastController,
    private modalCtrl: ModalController) { }

  signIn() {
    const loginModal = this.modalCtrl.create(LoginModalPage);
    loginModal.present();
    loginModal.onDidDismiss(toast => {
      if (toast) {
        this.toastCtrl.create({
          message: toast,
          duration: 3000,
          position: 'bottom'
        }).present();
      }
    })
  }
}

```

usage:

```auto
<ion-header>
  <custom-nav [title]="'Search'"></custom-nav>
</ion-header>

```

screenshot:

 ![48%20AM](https://global.discourse-cdn.com/ionicframework/original/3X/0/8/0851e35da83567e29832829fc0a5fc250ccdc026.jpg)

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:42pm UTC](https://forum.ionicframework.com/t/refactoring-ion-navbar-into-custom-component-causing-overlap/126282/2 "2021-07-19T21:42:37Z")

</div>

Closed on July 19, 2021, 9:42pm UTC


