Sticky headers changing style as you scroll can be seen on Luma's site, adding a polished feel to the UI.
Detection of when a sticky element becomes sticky is not straightforward, as there is no built-in way to do so using CSS or JavaScript events.
The author explores replicating the sticky header effect using the IntersectionObserver API, a lightweight and widely supported solution that provides opportunities for various interactions.
While container queries are a promising future option for detecting sticky elements, they are currently only available in Chrome, leaving IntersectionObserver as a practical choice for now.