Check out example codes for "sticky mat-toolbar". It will help you in understanding the concepts better.

Code Example 1

.app-toolbar {
    position: sticky;
    position: -webkit-sticky; /* For macOS/iOS Safari */
    top: 0; /* Sets the sticky toolbar to be on top */
    z-index: 1000; /* Ensure that your app's content doesn't overlap the toolbar */

Learn ReactJs, React Native from