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.
12345{ "rules": { "systomic/dropdown-scroll-padding": "warn" }}See the difference
- Design
- Engineering
- Finance
- Marketing
- Operations
- Product
- Research
- Sales
- Support
className="max-h-48 overflow-y-auto p-2"- 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 findings12345678910111213141516171819import { Select } from "radix-ui";
export function TeamSelect() { return ( <Select.Root> <Select.Content className="max-h-64 overflow-y-auto p-1"> <Select.Item value="general">General</Select.Item> </Select.Content> </Select.Root> );}
export function SearchResults() { return ( <ul role="listbox" style={{ overflowY: "auto", paddingBlock: 4 }}> <li role="option">Finance</li> </ul> );}systomic/dropdown-scroll-padding <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.
systomic/dropdown-scroll-padding <ul> scrolls and has paddingBlock: 4, but no scroll padding: an item scrolled into view with the keyboard sits flush against the edge. Add scrollPaddingBlock: 4.
Stylelint
1 finding12345.select-content { max-height: 16rem; overflow-y: auto; padding: 4px;}systomic/dropdown-scroll-padding .select-content scrolls and has padding: 4px, but no scroll padding: an item scrolled into view with the keyboard sits flush against the edge. Add scroll-padding-block: 4px.
What works
No findingsOxlint
123456789101112131415161718192021222324import { Select } from "radix-ui";
export function TeamSelect() { return ( <Select.Root> <Select.Content className="max-h-64 overflow-y-auto p-1 scroll-py-1"> <Select.Item value="general">General</Select.Item> </Select.Content> </Select.Root> );}
export function SearchResults() { return ( <ul role="listbox" style={{ overflowY: "auto", paddingBlock: 4, scrollPaddingBlock: 4 }}> <li role="option">Finance</li> </ul> );}
/** Scrolling content that isn't a dropdown list. */export function Article() { return <article className="max-h-96 overflow-y-auto p-6" />;}Stylelint
123456.select-content { max-height: 16rem; overflow-y: auto; padding: 4px; scroll-padding-block: 4px;}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.
12<Select.Content className="max-h-64 overflow-y-auto p-1" /> // reported, fixed:<Select.Content className="max-h-64 overflow-y-auto p-1 scroll-py-1" />
<Select.Content>scrolls and hasp-1, but no scroll padding: an item scrolled into view with the keyboard sits flush against the edge. Addscroll-py-1.
Reported when an element:
- is a dropdown list: its name (
Select…,Combobox…,DropdownMenu…,Menu…,Popover…,Listbox…, cmdkCommandList),role="listbox"/"menu", names incomponents, or it sits in one (<Popover.Content><div …>,function SelectContent()), - scrolls:
overflow-y-auto,overflow-auto,overflow-*-scroll,overflow/overflowYin 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 |