rule 03 — tier 2

A scroller on one axis says what the other axis does

overflow-x-auto alone also scrolls vertically, because CSS will not keep one axis visible while the other clips. Write the other axis next to it — overflow-x-auto overflow-y-hidden, overflow-y-auto overflow-x-hidden — or use overflow-auto if both really scroll.

warnlintscroll-on-one-axis-names-the-other

element usage

Layout is yours. Appearance is the library's.

what this catches

An agent makes a tab strip, a chip row or a code block scroll sideways with `overflow-x-auto`, sees it work, and ships a 1px vertical scrollbar: something inside hangs a pixel past the box — the selected tab's underline laid over the list's border, a focus ring, a negative margin — and the browser offers to scroll to it. It looks right in the screenshot that was checked, and wrong on the next platform, zoom level or theme.

why

`overflow-x: auto` with `overflow-y` left alone does not mean "scroll sideways, leave the vertical axis as it was". The spec computes `visible` on one axis to `auto` when the other is not `visible`, because a box cannot both clip and not clip its content. So a one-axis class is a two-axis scroller, and the axis nobody wrote down scrolls too.

A scroller clips at the inside of its border, and plenty of things are drawn a pixel or two past it on purpose: the selected tab's underline moved down 1px to sit on the list's hairline, a focus ring with an offset, a `-mb-px` that merges two borders. Each of those is invisible overflow until the parent becomes a scroller — then it is a scrollbar, on the axis nobody was thinking about, sized to a single pixel. Where scrollbars overlay (macOS by default) it only shows while scrolling, which is how it gets through review and turns up on someone else's machine.

The fix is to name the other axis in the same class list: `overflow-x-auto overflow-y-hidden` for a strip, `overflow-y-auto overflow-x-hidden` for a list. `hidden` clips exactly what `auto` clipped — that was never optional — and stops offering a scrollbar for it. If the overhang is something the reader must see, the class does not fix it: move it inside the box (`bottom-0` instead of `-bottom-px`, an inset ring, a `p-1` that leaves the ring room), because a scroller cannot show anything past its edge on either axis. If content really can be larger than the box both ways, that is `overflow-auto`, and writing it says so.

It warns rather than fails. Most hits are a missing class with an obvious value, but which value — `hidden`, or a second `auto` because the content really can be wider — depends on the content, and that is a judgement the linter cannot make. The examples carry `relative` because a scroll container is also a positioning context — that is position-scroll-containers, a different bug in the same class list.

wrong / right

A tab strip that scrolls sideways

don't

<Tabs>
  <TabList className="relative overflow-x-auto" aria-label="Sections">
    <Tab id="overview">Overview</Tab>
    <Tab id="activity">Activity</Tab>
    <Tab id="settings">Settings</Tab>
  </TabList>
</Tabs>

do

<Tabs>
  <TabList className="relative overflow-x-auto overflow-y-hidden" aria-label="Sections">
    <Tab id="overview">Overview</Tab>
    <Tab id="activity">Activity</Tab>
    <Tab id="settings">Settings</Tab>
  </TabList>
</Tabs>

The selected tab's underline sits 1px below the tab, on top of the list's hairline — which is the list's border, and a scroller clips at the inside of its border. With overflow-y left alone that pixel became a vertical scrollbar. overflow-y-hidden says there is nothing to scroll to vertically, which was always true.

A list that scrolls down

Was real code in src/components/async-select.tsx, until it was fixed

don't

<div className="quebi-scrollbar relative max-h-72 overflow-y-auto overscroll-contain p-1">
  {options}
</div>

do

<div className="quebi-scrollbar relative max-h-72 overflow-y-auto overflow-x-hidden overscroll-contain p-1">
  {options}
</div>

The same rule turned sideways: a focus ring or a long unbroken label one pixel wider than the list gave it a horizontal scrollbar. A list scrolls down; across it has nothing to offer.

Both axes scroll — say both

don't

<div className="relative overflow-x-auto">
  <pre>{source}</pre>
</div>

do

<div className="relative overflow-auto">
  <pre>{source}</pre>
</div>

When the content really can be wider and taller than the box — a code block in a fixed-height panel — a two-axis scroller is the design, and overflow-auto writes down what overflow-x-auto was already doing.

how to check this

Add one of these to your project and the rule holds without anyone having to remember it — including the agent writing half the JSX. The exceptions below are already applied, so a documented carve-out will not be reported.

What it will and will not catch: The check reads one string literal at a time. It catches the one-axis class written alone, which is the whole bug; it does not see a class list assembled from a template literal, and it reports a list whose two axes were split across two strings of the same cn() call. It cannot see the overhang itself — whether a child is drawn past the box is a question about layout, not about the class list — so the class it asks for stops the scrollbar, and moving the overhang inside the box is still yours if it has to be visible. The ripgrep line finds every one-axis scroller; which of them name the other axis is a review question.

Biome — GritQL plugin

biome

Biome has no built-in rule for this one, so it ships as a GritQL plugin. Save it as ui-lib-rules/scroll-on-one-axis-names-the-other.grit and load it from an `overrides` entry — the one in the file's own header, which lists the paths the rule applies to (app/**/*.{tsx,jsx}, src/**/*.{tsx,jsx}) and the paths its documented exceptions carve back out. Not from the top-level `plugins`: a plugin listed there runs against every file you lint, and an override can add one but cannot take one away. If your project keeps its components somewhere else, edit the `includes` to match.

// A scroller on one axis says what the other axis does
// AUTO-GENERATED from https://ui-lib.quebi.de/api/rules/scroll-on-one-axis-names-the-other.json — do not edit by hand.
//
// https://ui-lib.quebi.de/rules/scroll-on-one-axis-names-the-other
//
// This file says what the rule is, not where it applies. A plugin listed in
// the top-level `plugins` runs against every file Biome lints, so scope it
// with an `overrides` entry — Biome resolves `includes` against the project
// root, which is the one thing a $filename regex in here could not do:
//
//   {
//     "overrides": [
//       {
//         "includes": [
//           "app/**/*.{tsx,jsx}",
//           "src/**/*.{tsx,jsx}"
//         ],
//         "plugins": [
//           "./ui-lib-rules/scroll-on-one-axis-names-the-other.grit"
//         ]
//       }
//     ]
//   }

language js;

or { string(), JsxString() } as $classes where {
  $classes <: or {
    and {
      r".*\boverflow-x-(?:auto|scroll)\b.*",
      not r".*\boverflow-(?:y-[a-z]+|auto|scroll|hidden|clip|visible)\b.*"
    },
    and {
      r".*\boverflow-y-(?:auto|scroll)\b.*",
      not r".*\boverflow-(?:x-[a-z]+|auto|scroll|hidden|clip|visible)\b.*"
    }
  },
  register_diagnostic(
    span = $classes,
    message = "A scroller on one axis scrolls on both: CSS turns the other axis's `visible` into `auto`, so a pixel hanging past the box (an underline, a focus ring) becomes a scrollbar. Name the other axis in the same class list — overflow-x-auto overflow-y-hidden, overflow-y-auto overflow-x-hidden — or write overflow-auto if both really scroll. See https://ui-lib.quebi.de/rules/scroll-on-one-axis-names-the-other",
    severity = "warn"
  )
}

ripgrep — no setup at all

ripgrep

Finds candidates for review in any repo, linter or not. Coarser than the Biome check: it reads lines, not syntax, so expect false positives and treat a clean run as weaker evidence than a clean lint run.

# scroll-on-one-axis-names-the-other — candidates for review
rg -n -g '*.{jsx,tsx}' \
  "overflow-[xy]-(auto|scroll)"

Claiming an exception that is not a path

biome

One exception on this rule is a judgement call, so it cannot be a path. Biome's suppression syntax has a slot for the reason — fill it, because that note is what makes the carve-out reviewable instead of invisible. The rule is named by its plugin's file name, scroll-on-one-axis-names-the-other.grit — a suppression that names this rule quiets this rule and no other plugin on the same line, and if the file is renamed Biome reports the comment as having no effect rather than guessing. `lint/plugin` on its own is valid too and quiets every plugin rule on the node at once; name the rule instead.

// biome-ignore lint/plugin/scroll-on-one-axis-names-the-other: A class list split across strings — The check reads one string at a time, so `cn("overflow-x-auto", "overflow-y-hidden")` is reported for the first string even though the element is fine.

// Between JSX children, where a comment has to be an expression, the same
// line is written {/* biome-ignore … */}.

Enforcing more than this one rule? Take the whole config instead of collecting snippets.

exceptions

Carve-outs are part of the rule, not a way around it. Each one is already an ignore glob in the checks above, so the cases listed here need no disable comment — and a case that is not listed is one to argue for, not to silence.

A class list split across strings
The check reads one string at a time, so `cn("overflow-x-auto", "overflow-y-hidden")` is reported for the first string even though the element is fine. Put both axes in the same string — they are one decision, and they read better together — rather than suppressing it.

scope and enforcement

Applies to
  • app/**/*.{tsx,jsx}
  • src/**/*.{tsx,jsx}
Enforced by
lint