Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a web page, choose the trigger that matches the design: use an IntersectionObserver with sentinels when the search bar should respond to the header entering or leaving its sticky state; use scroll position or direction only when the intended rule is explicitly tied to a threshold or scrolling upward. For a native iOS navigation bar, UIKit provides hidesSearchBarWhenScrolling. Whichever approach you use, keep keyboard focus visible and account for reduced-motion preferences.

Choose the behavior before choosing the implementation

“Show or hide while scrolling” can describe different behaviors. Decide which one the interface actually needs:

  • Show at the top, collapse while scrolling: the search bar is available before the user scrolls and moves out of the way as content moves.
  • Change state when the header becomes sticky: the search bar responds to the header entering or exiting its sticky position.
  • Show on scroll up: the search bar reappears when the user reverses direction, regardless of whether the page is at the top.

These are not interchangeable triggers. The available web guidance describes observing sticky-state transitions and separately recognizes threshold- or direction-based rules; it does not establish one universally best trigger for every layout.

For a web page, use sticky-state detection when the header’s sticky state matters

If the search bar should change as a header enters or exits position: sticky, use IntersectionObserver sentinels placed around the relevant region. Chrome for Developers describes a two-sentinel pattern that can distinguish transitions while scrolling in either direction. It recommends using an observer instead of scroll events to determine when headers enter and exit sticky mode: An event for CSS position: sticky.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This approach ties the change to the actual sticky transition rather than repeatedly checking scroll position. Keep the state change small and predictable; avoid unnecessary layout recalculation as the user scrolls.

Use scroll position or direction only for a deliberate rule

A threshold rule, such as showing the search bar only near the top, differs from a show-on-scroll-up rule. If you choose either, define the threshold or direction change and the behavior at the top and at direction reversals. Then test that the search remains discoverable and keyboard-operable. Do not treat a direction-based reveal as equivalent to detecting when the header becomes sticky.

For a UIKit navigation interface, use the built-in search behavior

When a search controller is integrated into a navigation item, configure that item’s searchController and set hidesSearchBarWhenScrolling. Apple documents true as showing the search bar at the top and collapsing it into the navigation bar when the user scrolls. Set it to false to keep the bar visible regardless of scroll position. This UIKit property applies to native iOS navigation interfaces, not web headers: Apple’s UINavigationItem documentation.

Make the interaction accessible

Respect reduced motion

If the search bar moves as it appears or disappears, provide a reduced-motion alternative. The W3C CSS technique uses @media (prefers-reduced-motion: reduce) to suppress nonessential motion: W3C Technique C39.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Keep keyboard focus from disappearing behind the header

Tab through the page with the header in its scrolled state, then navigate back through controls. A sticky header must not completely hide a focused component or its focus indicator; W3C identifies that concealment as a failure example for WCAG 2.2 Success Criterion 2.4.11: Understanding Focus Not Obscured (Minimum). Ensure the active control remains visible and make room for the header when moving focus or scrolling to a control: W3C Technique G132.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Compare the options

Approach Best fit Key consideration
IntersectionObserver sentinels Web layouts where the search bar responds to the header entering or exiting sticky mode Sentinels can distinguish sticky-state transitions while scrolling in either direction.
Scroll position or direction state Web layouts with an explicitly defined threshold or show-on-scroll-up behavior Specify thresholds and edge behavior; verify focus visibility and reduced-motion behavior.
hidesSearchBarWhenScrolling UIKit navigation interfaces with an integrated search controller Provides a built-in collapse-on-scroll behavior and requires a configured searchController.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.