Simplified Vice City UI illustration showing a half-open side drawer with a glowing neon pink edge being dragged rightward over a dimmed page

There is a new experimental feature in Chrome Canary right now that lets us build swipe-to-reveal menus, top drawers, and bottom sheets using only HTML and CSS. I love tinkering with early proposals like this, and once you figure out a few key CSS details around scroll-behavior, scroll chaining, and animations, the whole thing works surprisingly well. Let's take a look at what the specs say, where swipe affordances make sense on the web, and the CSS techniques behind five Vice City themed demos I built.

From time to time, I run into a feature that takes a bit more time to wrap my head around, and this is definitely one of those features. I should probably start by saying that this feature is brand new, experimental, and has the potential to change. At the moment of writing, you can play with it in Chrome Canary with the Experimental Web Platform Features flag enabled. Attribute names could in theory still change, the way it’s wired up as well, CSS properties might get tweaked, but generally speaking, it’s a feature worth exploring. This article might not be the most practical one, but I hope you can see this as a call to action to test this out.

Honestly though? I love tinkering with this kind of early web platform stuff, it’s been a while since I last tinkered with feature that was only in Canary. The core idea behind native overscroll areas is fantastic. It allow you to pull down a top drawer or swipe open a side menu without loading a single line of JavaScript gesture-tracking code. It seems simple, but it feels kind off addictive (I lost count how many times I did some swiping on these demos while building them). It’s one of those things I wish we had in the early touch-device era so that we could’ve built affordances on how to browse the web, more on that in a second.

Playing with this feature early on is important, and I hope this article will encourage you to do so. This is the exact moment to test it, push its limits, try and break it, and figure out how all the moving pieces fit together. Along the way I ran into a few fun CSS puzzles (like how to get button clicks to slide smoothly and how to chain swipes properly), plus one or two UX, accessibility, and wrapper questions worth talking about.

What are Overscroll Areas?

The feature is being incubated across two places right now: the Declarative Overscroll Actions explainer in Open UI (authored by Vladimir Levin, Robert Flack, and Mason Freed), and the first draft of the CSS Overscroll Behavior Module Level 2 specification (CSSWG PR #14532, edited by Robert Flack).

Historically, if you wanted a drawer menu or a pull-down panel that responded to touch swipes, you had two options. Option one being writing a bunch of JavaScript listening to touchstart, touchmove, and touchend, manually calculating velocities, rubber-banding, focus traps, and inert states. Even if there are libraries for that, it was sort of a hassle. I know some people “hacked” this before with CSS Scroll Snapping as well by putting the menu and the main page inside a giant horizontal flex scroller. It (visually) worked, but wasn’t a real solution.

Wait… should we actually swipe on a website?

When I started building demos with overscrollarea, my mind went in two directions: “oh wow, this is so smooth” and “wait… should we actually do this on a website?”.

On desktop, people are using a mouse, a trackpad, or a keyboard. Nobody goes around dragging an invisible left edge of a webpage hoping a menu slides out, that’s not really the point of this feature, it is mostly about touch-devices. That being said… on mobile browsers, swiping in from the left or right edge of the screen already has a very strong OS and browser affordance, such as going back or forward in your browsing history. Trying to hijack or compete with that on a regular content site feels awkward to me.

Where I do see a real benefit, however, is in PWAs (Progressive Web Apps). When someone installs an app to their home screen, browser UI disappears and expectations are different. Having a native, compositor-smooth way to make PWAs feel closer to native apps without shipping heavy touch libraries makes sense.

Take me down to the Vice City, where the grass is green and the demos are pretty

Let’s walk through the feature step by step using five demos I built.

Quick bit of background on the look and feel: I had a bunch of really heavy weeks and wasn’t able to get some decent hours in the newly released GTA6. So… the choice of design is partially me fanboying over corner-shape combined with a desire to drive around in Vice City, and testing a new feature.

Side note: Did you know you can play GTA 1 in JS? I saw a cool talk at our local devs.gent meetup by Bramus on how he made GTA in JS

Remember to open these CodePen demos in Chrome Canary with the experimental flag turned on.

Demo 1: HTML wire-up, mandatory invokers, and a top drawer

Let’s start with a classic mobile OS pattern: pulling down from the top of the screen to check notifications (or live dispatches in the demo).

To set this up, we need to use two new boolean attributes:

  • overscrollcontainer: Placed on the parent container (like <body> or an app wrapper) to tell the browser it can host overscroll areas beyond its scroll boundaries. This element doesn’t actually have to overflow or have a scrollbar. If its content fits on screen, it is simply considered to already be at its scroll boundary, so swiping immediately chains into the overscroll area.
  • overscrollarea: Placed on a direct child of that container. This is your “hidden drawer”.

Mandatory Invoker Commands for UX and accessibility

Before I even went deep-diving in this feature I was already thinking that edge-swiping isn’t an obvious affordance on the web and that I would always include a clear, visible trigger button purely for good UX, but also for accessibility as not everybody uses a touchscreen, and not everybody has the motor capability to perform a swipe gesture. But to my surprise this was already in the specifications: spec authors actually enforce this in HTML!

You have to add an invoker command to get this to work

According to the spec, an element is only recognized as a valid overscroll area if it is the target of at least one show-overscroll or toggle-overscroll invoker command in the same tree scope. If you delete that <button>, the overscroll behavior simply deactivates and the element falls back to laying out like a normal child. I love that! If authors forget to add it, it becomes obvious something isn’t right, without relying on DevTools to give you a warning.

There are three new values for the command attribute (paired with commandfor="your-id"):

  • command="toggle-overscroll": Opens the overscroll area if it’s closed, or closes it if it’s open.
  • command="show-overscroll": Opens the overscroll area.
  • command="hide-overscroll": Closes the overscroll area (great for a close button inside the drawer, though clicking the backdrop already closes it by default, so closedby="any" is sort of baked-in here).

There is even a clever exception in the inertness rules for toggle-overscroll: if you place a toggle button inside your [overscrollarea] and position it so a little tab peeks out into the main viewport while the drawer is closed, that button automatically escapes the closed drawer’s inert state so keyboard and mouse users can still activate it. I don’t know who to credit for this, but that’s a nice find. Details are important.

Of course, from a UX standpoint, we still have a responsibility as authors not to style that required button into a tiny, barely noticeable pixel in the corner just because we want a “gesture-first” interface. But the same counts for dialogs and/or popovers for example.

Here is how our first demo wires that up in HTML:

<body overscrollcontainer>
  <aside id="notification-shade" overscrollarea aria-label="Vice City Police Scanner">
    <div class="shade-header">
      <h2>Leonida Live Scanner</h2>
      <button command="hide-overscroll" commandfor="notification-shade">
        Close
      </button>
    </div>
    <!-- Scanner cards... -->
  </aside>

  <header class="site-nav">
    <button command="toggle-overscroll" commandfor="notification-shade">
      Scanner (03)
    </button>
  </header>

  <main>
    <!-- Main page content... -->
  </main>
</body>

States, automatic inertness, and the backdrop

CSS Overscroll Level 2 introduces two state pseudo-classes on [overscrollarea], pretty much like we have in popovers:

  • :overscroll-open: Matches when the panel is snapped (or snapping) into the open state.
  • :overscroll-closed: Matches when the panel is closed.

By default, the browser’s user-agent stylesheet applies interactivity: inert to :overscroll-closed. Imagine a keyboard user pressing Tab down your page. If links inside an off-screen menu were still focusable, tabbing into one would force the browser to scroll that link into view. Making :overscroll-closed inert automatically prevents that, and when :overscroll-open matches, the background content becomes inert instead. Free/smart focus traps, it’s great.

In CSS, we set overscroll-container-type: overlay on the body alongside overscroll-behavior-y: contain so vertical overscrolling stays contained rather than triggering browser-level pull-to-refresh, and we place the #notification-shade right above the top edge with inset-block-end: 100%:

body {
  overscroll-container-type: overlay;
  overscroll-behavior-y: contain;
}

#notification-shade {
  inset-block-end: 100%;
  inline-size: 100%;
  max-block-size: 85dvh;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  scroll-behavior: smooth;

  &::backdrop {
    background-color: rgb(8 9 20 / 0.76);
    backdrop-filter: blur(4px);
  }
}

Smooth button transitions and swiping closed

Two small properties on #notification-shade are quite important:

  • scroll-behavior: smooth on the [overscrollarea]: Opening or closing via command="toggle-overscroll" and command="hide-overscroll" scrolls an internal container rather than animating a CSS translate. Setting scroll-behavior: smooth directly on #notification-shade (not on html or body) makes button clicks slide smoothly instead of snapping instantly.
  • overscroll-behavior-y: auto: Keeping vertical overscroll set to auto on the top drawer lets upward swipes directly on the <aside> chain back up to the parent container and push the drawer closed.

Some caveats or missed opportunities?

Each overscroll area comes with a built-in ::backdrop that supports light-dismiss on click. One bleeding-edge Canary note here: the CSSWG draft specifies this pseudo-element as ::overscroll-backdrop, whereas in the current Chrome Canary prototype I tested, it is exposed as ::backdrop directly on the [overscrollarea] element. Keep that in mind. I do hope the Canary example will be the default one. I usually want consistency in my backdrops and like to style those in one go.

I did notice that pressing the escape key did not close the drawer. I’m not sure if this is by design, or a “yet-to-implement”. I didn’t find anything in the spec as well.

Demo 2: Positioning, the scroll-snap box model, and a left drawer

So how did the browser know in Demo 1 that our drawer had to pull down from the top? And how do we change that to a left-hand drawer for our second location?

Under the hood, for every valid [overscrollarea], the browser wraps it in an anonymous scroll container (which the spec calls the overscroll area parent, they love naming things in specland) with default styles along these lines:

/* Internal anonymous overscroll area parent */
position: absolute;
inset: 0;
overflow: auto;
scrollbar-width: none;
scroll-snap-type: pair mandatory;

The [overscrollarea] itself becomes position: absolute inside that hidden scroller.

Unlike a normal scroll container, this internal scroller allows scrollable overflow in all four directions (including negative top and left offsets!), and sets up two mandatory scroll-snap points: one at (0, 0) (closed) and one on your [overscrollarea] (open). Because of pair mandatory snapping, a user can never accidentally leave your menu hanging halfway open.

At the moment, it seems it won’t be possible to have a small drag only to show your most important notifications and a bigger drag to show the full list. Not sure if that would be good UX to begin with, but just putting it out there.

Using logical properties (assuming a standard horizontal-tb, left-to-right writing mode), you park your panel just past whichever edge you want:

/* Pull down from the top edge */
#top-drawer {
  inset-block-end: 100%;
}

/* Swipe right from the left edge */
#left-drawer {
  inset-inline-end: 100%;
}

/* Swipe up from the bottom edge (bottom sheet) */
#bottom-sheet {
  inset-block-start: 100%;
}

/* Swipe left from the right edge */
#right-drawer {
  inset-inline-start: 100%;
}

Easy as that, the only difference in demo 2 is that instead of inset-block-end: 100%, we place the #side-menu past the inline-start edge using inset-inline-end: 100% and set the overscroll-behavior to contain on the x-axis.

body {
  overscroll-container-type: overlay;
  overscroll-behavior-x: contain;
}

#side-menu {
  inset-inline-end: 100%;
  inline-size: var(--drawer-width);
  block-size: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}

Once again, adding scroll-behavior: smooth directly on #side-menu makes our hamburger and close buttons animate smoothly as well.

Demo 3: Quick settings with scroll-triggered and scroll-driven animations

Once I had the basics covered, I kinda wanted to push the motion design to what you see on Android or iOS when you pull down quick settings. You see those notifications, sliders, and toggles stagger and animate into place.

A hot tip: when a top drawer pulls down from inset-block-end: 100%, its bottom edge enters the viewport first. That means if you stagger your items top-down, the header animates off-screen before the user can even see it. Running the stagger bottom-up, makes the interaction feel a lot more natural.

I split this into two separate demos, Demo 3A and Demo 3B, so you can compare a threshold-triggered reveal against a continuous drag-scrubbed reveal. Both work, my preference goes to the scroll-driven example tho.

Demo 3A: Staggered thresholds with scroll-triggered animations

In Demo 3A, we use CSS scroll-triggered animations by setting four timeline-trigger thresholds on #notification-shade (separated in tiers per row: --tier-1 through --tier-4, spanning exit 68% to exit 90%). As you pull the drawer past each threshold, that tier fires its own time-based 0.55s easing curve (play-forwards), and reverses (play-backwards) as soon as closing begins:

#notification-shade {
  inset-block-end: 100%;
  overscroll-behavior-y: auto;
  scroll-behavior: smooth;
  view-timeline: --shade-timeline block;
  timeline-trigger:
    --tier-1 view() exit 68% exit 105%,
    --tier-2 view() exit 76% exit 105%,
    --tier-3 view() exit 83% exit 105%,
    --tier-4 view() exit 90% exit 105%;
}

.shade-header,
.qs-tile,
.brightness-bar,
.notif-item {
  animation: shade-item-reveal 0.55s var(--ease-out) both;
}

/* Bottom-up order: bottom notification fires first, header fires last */
.notif-item:last-child {
  animation-trigger: --tier-1 play-forwards play-backwards;
}

.brightness-bar,
.notif-item:first-child {
  animation-trigger: --tier-2 play-forwards play-backwards;
}

.qs-tile:nth-child(n + 3) {
  animation-trigger: --tier-3 play-forwards play-backwards;
}

.shade-header,
.qs-tile:nth-child(-n + 2) {
  animation-trigger: --tier-4 play-forwards play-backwards;
}

It works, but it also feels a bit hard to maintain. A better idea is scroll-driven…

Demo 3B: Mimicking native drag physics with scroll-driven animations

Instead of firing timed animations at fixed thresholds, we mimic a native “touch-drag scrub” using scroll-driven animations paired with sibling-count() and sibling-index().

Because pulling the overscroll panel with your finger or trackpad is literally scrolling that hidden container from exit 0% (closed) to exit 100% (fully open), we can assign a bottom-up --step index to each row and spread their animation-range windows across the full pull distance:

.notif-item {
  --step: calc(sibling-count() - sibling-index());
}

.brightness-bar {
  --step: 2;
}

.qs-tile {
  --step: calc(3 + sibling-count() - sibling-index());
}

.shade-header {
  --step: 7;
}

:is(.shade-header, .qs-tile, .brightness-bar, .notif-item) {
  --start: calc(var(--step, 0) * 9%);
  --end: calc(37% + var(--step, 0) * 9%);
  animation: shade-item-reveal auto linear both;
  animation-timeline: --shade-timeline;
  animation-range: exit var(--start) exit var(--end);
}

This mimics that native mobile quick-settings drag closely. To be honest, if you do it by row it might be even better, I now used sibling counting so each item has a different step instead of each row.

Demo 4: Combining top and side panels (and a small step towards div-soup)

What if you need both a side-opening navigation panel and a top-opening area? For the fourth demo, I wanted to combine both directions.

Semantically, both of those panels live at the root of the application. You somehow, hope you could do something like this:

<!-- What you expect to write (causes cross-axis conflicts) -->
<body overscrollcontainer>
  <aside id="notification-shade" overscrollarea>...</aside>
  <nav id="side-menu" overscrollarea>...</nav>
  <main>...</main>
</body>

However, when you place two panels on adjacent axes (one vertical, one horizontal) on the same container, things get messy fast. Diagonal swipes can bleed across axes, scroll chaining order becomes awkward, and overscroll-behavior works against you because you can’t isolate vertical containment (overscroll-behavior-y: contain) from horizontal containment (overscroll-behavior-x: contain) per panel on one shared container.

The only reliable way to make both a top drawer and a side drawer work together right now is to nest two separate overscrollcontainer elements, one per axis:

<!-- Outer container owns the vertical (block) axis -->
<body overscrollcontainer>

  <aside id="notification-shade" overscrollarea>
    <!-- Top radar drawer -->
  </aside>

  <!-- Extra wrapper required just to own the horizontal (inline) axis -->
  <div class="app-shell" overscrollcontainer>

    <nav id="side-menu" overscrollarea>
      <!-- Left vehicle fleet drawer -->
    </nav>

    <header class="site-nav">...</header>
    <main class="main-stage">...</main>
  </div>

</body>
/* Outer container handles vertical pull-down */
body {
  overscroll-container-type: overlay;
  overscroll-behavior-y: contain;
}

/* Inner wrapper handles horizontal swipe-right */
.app-shell {
  min-block-size: 100dvh;
  overscroll-container-type: overlay;
  overscroll-behavior-x: contain;
}

It works smoothly in the demo if you do it like that. Still, I have some thoughts on this. Having to write that extra .app-shell wrapper feels a bit icky and a bit makes me wonder if there isn’t a better way.

I always try to avoid polluting my HTML structure for purely technical or visual reasons. We have come such a long way in CSS (with Grid, subgrid, :has(), anchor positioning, and gap decorations) specifically so we don’t have to wrap everything in arbitrary <div>s anymore. Surely there can be a fix for it? I’m just hoping we’re not going to get a bunch of div-soup.

My hope is that because this spec is still in its exploring phase, overscroll-container-type: overlay (or per-area axis locking) can evolve so sibling overscrollarea elements on adjacent edges lock cleanly to whichever single axis the user started swiping along, all inside one semantic container.

But you can create something like this:

Demo 5: Layout modes with overscroll-container-type and scroll chaining

In all four demos so far, the panels slid over the page using overscroll-container-type: overlay. For the fifth demo, I built an interactive playground to test the remaining layout modes and the new scroll-chaining behavior.

Switching layout modes with overscroll-container-type

On the [overscrollcontainer], overscroll-container-type controls how the panel interacts with the rest of your page when it slides in:

overscroll-container-type: auto | push | overlay | none;
  • push (and auto, which currently behaves like push): Opening the overscroll area physically moves the container’s main content out of the way by the same scroll offset.
  • overlay: Only the overscroll area moves, sliding right over the top of your page content.
  • none: Disables the overscroll container.

That none value is actually important here. In Demo 5’s Responsive Grid mode, body uses overscroll-container-type: overlay on narrow viewports, and inside a @media (width >= 900px) query it flips to overscroll-container-type: none while docking #side-menu into a regular two-column CSS Grid:

body {
  overscroll-container-type: overlay;
  overscroll-behavior-x: contain;

  @media (width >= 900px) {
    display: grid;
    grid-template-columns: var(--drawer-width) minmax(0, 1fr);
    align-items: start;
    overscroll-container-type: none;

    #side-menu {
      position: sticky;
      inset: 0;
      block-size: 100dvh;
    }

    .nav-hamburger {
      display: none;
    }
  }
}

This is nice if you want your mobile nav to be a sidebar on desktop and a drawer on mobile.

Handing off inner scrollers with overscroll-behavior: chain

What happens when you have a horizontally scrollable container or photo reel inside a page that also has a left-sliding overscrollarea drawer? (pretty much like on the homepage of this blog).

Alongside overscroll areas, CSS Overscroll Level 2 updates overscroll-behavior with a fourth keyword: chain. Previously we had auto, contain, and none .

The new chain keyword completes the matrix: no local bounce effect, while still allowing scroll chaining to an ancestor. In the demo you can switch between all four keywords on the .photo-reel scroller and swipe right past its start edge to feel the difference:

.photo-reel {
  overflow-x: auto;
  overscroll-behavior-x: chain;
}

Here is that demo, i added a video below, but didn’t cover all the options. Do check it out yourself.

With contain or none, hitting the start of the photo reel stops dead and never opens the drawer. With auto or chain, dragging past the first photo brings the gesture straight up to the parent [overscrollcontainer] to pull out #side-menu, with chain. You really get a bunch of great UX options in here.

JavaScript events when you need a hook

Even though the whole point is zero-JS menus, sometimes we need to run a bit of logic, like fetching fresh data. The spec adds four OverscrollEvent types that can be dispatched on the overscrollcontainer, I’m adding them here for completeness sake, but haven’t tested those (fair is fair):

  • overscrollstart: Fired when the overscroll parent begins scrolling or changing snap targets.
  • overscrollchanging: Fired mid-gesture when the eventual snap target flips between closed and open.
  • overscrollend: Fired when scrolling finishes and the snapped state actually changed (e.g., from closed to open).
  • overscrollcancel: Fired when scrolling finishes right back where it started (the user pulled halfway and let go).

Tinkering today for a better spec tomorrow

I had a few thoughts here:

  • Should the escape key close the panel?
  • Can we have more than one pannel on one parent? Reducing extra divs.
  • Do we feel this can become an affordance on the mobile web, or its more a PWA-thing?

That being said, look at everything we didn’t have to write a single line of JavaScript for: touch tracking, velocity snapping, smooth button transitions, staggered scroll-driven and scroll-triggered animations, modal inert toggling, keeping closed off-screen links out of the Tab order, light-dismiss backdrops, and accessible <button> triggers via Invoker Commands. It’s mind-blowing.

HTML and CSS are really handling UI and layout better as they should. This might be one of those features where I hope we had it years ago as we could’ve created affordances towards how to navigate the web. And I’m sure that some will say that this should’ve stayed JavaScript territory, and in some way, I respect that opinion, but having this built-in the browser gets a lot of things right that could horribly go wrong when custom made. I like the idea behind this feature as another tool in the toolbox.

If you have Chrome Canary installed, go flip the experimental flag, play around with overscrollcontainer and overscrollarea, and see how it feels in your hands. And if you have use cases or run into things such as the multi-axis wrapper, add your thoughts on the Open UI issue or the CSSWG draft discussion. Now is the best time to help shape this feature to be perfect.

Now I’m off to get some well-deserved hours in Vice City.

 in HTML, CSS, UX, Accessibility