Native scrolling without a second interaction model
Keep platform momentum, wheel, touch and keyboard scrolling. The named region is keyboard-focusable only while content overflows.
Keyboard
- Tab to the overflowing region and use Arrow keys, Page Up, Page Down, Home and End.
- Scroll naturally with a wheel or touch gesture. Pinch zoom remains available.
- The region drops out of the tab order when the content fits.
States covered
- native momentum
- named region
- automatic keyboard entry
- horizontal and vertical overflow
- dynamic content
- unrestricted browser zoom
Install this complete example and its component dependencies.
npx shadcn@latest add https://ui.bld8.dev/r/example-scroll-area-native-region.jsonComplete source
/*!
MIT License
Copyright (c) 2026 Jaison
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import { useState } from 'react';
import { Button, ScrollArea, UIProvider } from '@bld8/ui';
export default function NativeScrollAreaExample() {
const [expanded, setExpanded] = useState(true);
return <UIProvider><div style={{ display: 'grid', gap: 16, minWidth: 0 }}><Button variant="secondary" onClick={() => setExpanded(value => !value)}>{expanded ? 'Show short content' : 'Show overflowing content'}</Button>
<ScrollArea label="Reference notes" orientation="both" style={{ height: 240, maxWidth: '100%', border: '1px solid var(--bui-line)', borderRadius: 6, padding: 16 }}>
<div style={{ minWidth: expanded ? 680 : 0 }}>{Array.from({ length: expanded ? 18 : 1 }, (_, index) => <p key={index} style={{ marginBottom: 16 }}>Reference {index + 1} — keep the source, keyboard behaviour and expected result together.</p>)}</div>
</ScrollArea></div></UIProvider>;
}