systomic

Dropdown scroll padding

When the keyboard moves to an item outside a scrolling list, the browser scrolls it flush against the edge and ignores the padding. Scroll padding keeps the gap.

  • RuleIn recommended.json: breaking it breaks the design-system contract.
  • WarningShows in the editor and in CI output, but doesn't fail the run (unless you pass --deny-warnings).
  • StylelintThe same check runs on .css and .scss files through the Stylelint plugin.
  • Autofixoxlint --fix fixes it for you.

See the difference

Before
  • Design
  • Engineering
  • Finance
  • Marketing
  • Operations
  • Product
  • Research
  • Sales
  • Support
className="max-h-48 overflow-y-auto p-2"
After
  • Design
  • Engineering
  • Finance
  • Marketing
  • Operations
  • Product
  • Research
  • Sales
  • Support
className="max-h-48 overflow-y-auto p-2 scroll-py-2"

What doesn't work

Oxlint

2 findings

Stylelint

1 finding

What works

No findings

Oxlint

Stylelint

Details

A select, combobox or menu that scrolls usually has a bit of padding around its items. When the keyboard moves to an item outside the visible area, the browser scrolls it into view flush against the edge, ignoring that padding. scroll-padding-block tells the scroll container to keep the same gap.

<Select.Content> scrolls and has p-1, but no scroll padding: an item scrolled into view with the keyboard sits flush against the edge. Add scroll-py-1.

Reported when an element:

  • is a dropdown list: its name (Select…, Combobox…, DropdownMenu…, Menu…, Popover…, Listbox…, cmdk CommandList), role="listbox" / "menu", names in components, or it sits in one (<Popover.Content><div …>, function SelectContent()),
  • scrolls: overflow-y-auto, overflow-auto, overflow-*-scroll, overflow / overflowY in inline styles or StyleX,
  • has vertical padding: p-*, py-*, pt-*, pb-*, padding, paddingBlock, paddingTop / paddingBottom,
  • and no scroll padding: scroll-p-*, scroll-py-*, scroll-pt-* / scroll-pb-*, scrollPadding*.

The autofix appends the matching classes to a plain className string (p-1 → scroll-py-1, md:pb-2 → md:scroll-pb-2). For styles, the message names the value (scrollPaddingBlock: 4).

Not reported: scrolling content that isn’t a dropdown (dialogs, articles, sidebars).

In CSS (Stylelint), the same check runs per rule whose selector names a dropdown (.select-content, [role=listbox], .menu, also through nesting), including @apply.

Option Default
components []: extra dropdown component names
attributes, callees, styleAttributes see styling
Esc