# Ionic 5 Angular 10 Hide Header on Scroll

**URL:** <https://forum.ionicframework.com/t/ionic-5-angular-10-hide-header-on-scroll/207198>\
**Category:** showcase\
**Created:** [March 26, 2021, 8:36am UTC](https://forum.ionicframework.com/t/ionic-5-angular-10-hide-header-on-scroll/207198 "2021-03-26T08:36:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fathanyr](https://avatars.discourse-cdn.com/v4/letter/f/45deac/32.png) [@fathanyr](https://forum.ionicframework.com/u/fathanyr)\
**Post date:** [March 26, 2021, 8:36am UTC](https://forum.ionicframework.com/t/ionic-5-angular-10-hide-header-on-scroll/207198/1 "2021-03-26T08:36:08Z")

</div>

Thank’s for [hirenkorat3](https://forum.ionicframework.com/u/hirenkorat3)  
Cause of your post about hiding header on scroll. i able to create it in my project

This code improved for Ionic 5 Angular 10

Demo:  
 ![infinity](https://global.discourse-cdn.com/ionicframework/original/3X/f/f/ffeabddf250377a56e3bbbc7341629f7cfcc481e.gif)

in ts file

> [@](#):
>
> ```auto
> import { Component, ElementRef, Renderer2, ViewChild } from '@angular/core';
> 
> export class HideHeaderPage {
> @ViewChild("header") header: HTMLElement;
> 
> constructor(
> public element: ElementRef, 
> public renderer: Renderer2
> ) {
> }
> 
> // in my case i'm using ionViewWillEnter
> ionViewWillEnter() {
> this.renderer.setStyle(this.header['el'], 'webkitTransition', 'top 700ms');
> }
> 
> onContentScroll(event) {
> if (event.detail.scrollTop >= 50) {
> this.renderer.setStyle(this.header['el'], 'top', '-76px');
> } else {
> this.renderer.setStyle(this.header['el'], 'top', '20px');
> }
> }
> }
> 
> ```

in html file

> [@](#):
>
> ```auto
> <ion-header #header>
> <ion-navbar>
> <ion-title>
> Ionic Header
> </ion-title>
> </ion-navbar>
> </ion-header>
> <ion-content scrollEvents="true" (ionScroll)='onContentScroll($event)'>
> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum nam totam recusandae, iusto consequuntur quibusdam
> aliquid voluptate, placeat qui explicabo optio facilis similique doloribus aperiam animi voluptas, unde repellat
> sint?</p>
> </ion-content>
> 
> ```

reference from :[Hide Header and Footer on Scrolling with Animation](https://forum.ionicframework.com/t/hide-header-and-footer-on-scrolling-with-animation/143545)
