Fixed, sticky & frosted
Bars that stay on screen. .fixed-top and .fixed-bottom never move; .sticky-top and .sticky-bottom scroll with the page until they reach the edge, then stay. .frosted makes a bar see-through with the page blurred behind it.
Sticky inside a scrolling box
Inbox
New comment on Website redesign
Invoice 1042 is due tomorrow
Lucy approved the brand assets
Weekly planning moved to 2 PM
3 new signups today
5 messages
<div class="box p-0 h-64 overflow-y-auto">
<div class="sticky-top frosted border-b px-4 py-3 font-semibold">Inbox</div>
<div class="p-4 stack gap-3">
<div class="box p-3 bg-violet-soft">New comment on Website redesign</div>
<div class="box p-3 bg-yellow-soft">Invoice 1042 is due tomorrow</div>
<div class="box p-3 bg-green-soft">Lucy approved the brand assets</div>
<div class="box p-3 bg-pink-soft">Weekly planning moved to 2 PM</div>
<div class="box p-3 bg-cyan-soft">3 new signups today</div>
</div>
<div class="sticky-bottom frosted border-t px-4 py-3 hstack"><span class="text-sm text-muted">5 messages</span><span class="spacer"></span><button class="btn btn-sm btn-brand" type="button">Mark all read</button></div>
</div>Scroll the box: the header and footer stay put, and the cards show through them, blurred.
Classes
| Class | Does |
|---|---|
.fixed-top / .fixed-bottom | Stays at the top / bottom of the screen (layer 30). The bottom one keeps clear of a phone's home bar. |
.sticky-top / .sticky-bottom | Sticks once it reaches the top / bottom of its scrolling box (layer 20) |
.frosted | 78% see-through with a blur behind. --frost-bg picks the color (the surface by default). Browsers without blur get a solid background. |
Good to know
- A fixed bar covers the page under it: give the page matching padding (
pt-16for a 64px top bar). - Sticky needs room to move: it doesn't stick inside a box with
overflow: hiddenthat isn't the one scrolling.