Sticky headers and the iOS 26 status bar

On mobile, the menu on the new version of my site sticks to the top of the screen. As you scroll, it slowly darkens from the light page colour to a warm black.

Then I opened the page on my phone with iOS 26. The top of the screen, the status bar area above the page, turned dark too. And it stayed dark until I reloaded, even after I scrolled back up.

What Safari 26 is doing

With Liquid Glass, Safari tints the system area above the page to match the page. To pick the colour, it looks at what sits at the top edge. This is what I found with experiments on a real phone:

  • Safari reads the background-color (and backdrop-filter) of a sticky or fixed element at the top edge. It also reads its static children.
  • It does not read border-image, or anything outside the background.
  • It ignores the theme-color meta tag completely. That one only works on Android and in PWAs.

So when my sticky menu got a dark background, Safari used that dark colour for the status bar.

What didn't help

  • theme-color. Ignored, as above. I still keep <meta name="theme-color" content="#FCFBF8"> for Android.
  • An absolutely positioned child that carries the dark fill. This tip is around online. It didn't work on a real device.
  • A ::before pseudo-element for the fill. Same result.
  • A cover built on env(safe-area-inset-top). In portrait Safari it's 0, because the viewport starts below the status bar. There's nothing to build on.

The trick: paint the fill with border-image

The answer came from a site with the same kind of darkening menu, where the top of the screen stayed light. Its rules were hidden behind an @import, but the computed styles gave it away. The dark fill wasn't a background. It was a border-image.

The idea: keep background-color light all the time. The scanner sees light, so the top of the screen stays light. The dark colour goes into border-image, which is painted on top of the background. The scanner doesn't read it, but your eyes do.

Here's the mobile CSS from my site:

@media (max-width:1023px) {
  /* … */
  .side-stick { position:sticky; top:0; z-index:5; background:transparent; padding:0; }
  /* … */
  .side nav { display:flex; justify-content:flex-start; gap:.9em; overflow-x:auto; scrollbar-width:none;
    font-size:1.25rem; /* … */
    color:var(--ink); padding:16px 20px; background:var(--bg);
    border:0; border-image:conic-gradient(var(--tint) 0 0) 1 fill / 0 / 0 stretch; }
  /* … */
}

A few notes:

  • The sticky wrapper .side-stick is transparent. The fill lives on the nav inside it.
  • The nav background is --bg, which is #FCFBF8, the light page colour. It never changes.
  • conic-gradient(var(--tint) 0 0) is a gradient with one colour. It turns a colour into an image, and border-image needs an image.
  • 1 fill is the slice. The fill keyword paints the middle of the image, not only the edges.
  • / 0 / 0 sets the border-image width and outset to zero. With zero width, the middle covers the whole element.

If a browser can't do this, you get a light menu. Nothing breaks.

One warning if you copy this trick from somewhere else: some versions use a large outset, like 180px, which stretches the fill beyond the element. If a dark bar suddenly covers the whole screen, check the outset first.

Follow-up problem: Safari steps instead of fading

My first version animated the gradient itself in the keyframes. In Chrome that was a smooth cross-fade. In Safari it moved in steps. Safari doesn't interpolate border-image-source.

The fix is to animate a typed colour inside the gradient, not the gradient. Register the custom property with @property and syntax:'<color>', and the browser knows how to interpolate it:

@property --tint { syntax:'<color>'; inherits:false; initial-value:#FCFBF8; }
@keyframes stick-tint {
  0%     { --tint:#FCFBF8; color:var(--ink); }
  55%    { --tint:#77726C; color:var(--ink); }
  55.01% { --tint:#77726C; color:#fff; }
  100%   { --tint:#1B1815; color:#fff; }
}

The gradient in border-image stays the same. Only --tint changes. It's a registered colour now, so it fades smoothly.

Driven by scroll, no JavaScript

The animation runs on a scroll-driven timeline:

@media (max-width:1023px) {
  /* … */
  @supports (animation-timeline: scroll()) {
    .side nav { animation:stick-tint linear both; animation-timeline:scroll(root);
      animation-range:0px 540px; }
  }
  /* … */
}

The change starts with the first pixel of scroll and is done before the menu sticks. On a 375px wide screen my menu sticks at about 565px, so the range ends at 540px. That leaves a small margin.

No support for animation-timeline? The @supports block is skipped, --tint keeps its light initial value, and the menu stays light and readable.

Text colour: jump, don't fade

The fill can fade. The text shouldn't. If black text fades to white while the fill goes from light to dark, you get a moment of grey text on a grey background.

So the text jumps. Look at 55% and 55.01% in the keyframes. It's a double frame: the fill is the same mid grey, #77726C, and only the text flips from black to white. I chose a grey where both colours are readable. White on it is 4.8:1, our near-black text is 3.4:1.

One more thing smeared the jump: the links had transition: color. It blended the flip back into grey on grey. So on the mobile menu links, the transition is gone:

  .side nav a { white-space:nowrap; color:inherit; font-size:inherit; letter-spacing:.01em;
    transition:none; } /* … */

The reload quirk I left alone

One thing I didn't fix. Reload the page on iOS while you're scrolled down, and Safari paints the first frame from the top of the page. About 50ms later it jumps to your scroll position. I measured it frame by frame with a small diagnostic overlay.

That's how the platform behaves, and every site has it. You only notice it on sticky elements. I accepted it and didn't try to hide it behind a cover.

My checklist for sticky elements

Before I ship a sticky element now, I check:

  • On an iPhone, the top of the screen doesn't take the colour of the sticky element.
  • Reload while scrolled down, on desktop and on a phone: nothing jumps, apart from the platform quirk above.
  • During the colour change, there's no moment where the text blends into the fill.
  • The sticky point at 375, 390 and 430px wide: the animation range doesn't miss it.
  • Without JavaScript and without animation-timeline: the menu is readable, with the light fallback.
  • With prefers-reduced-motion: no movement is added. A colour change is fine.

I'll check all of this again with major iOS and Safari releases.

Further reading

← All notes

mihai@papush.ro