Scroll area
npx shadcn add @klarhimmel/scroll-areaCopy for AIExamples
List
Horizontal
Code
DetailsAbout, usage, props and more
Content that scrolls inside a fixed box: a named region, a tab stop, a thin scrollbar and a soft edge where there is more.
When to use
Use for
A list in a card, a code block or a strip that must not push the page.
Not for
Tables. Table scrolls itself. A whole page. Let the page scroll.
Pairs with
Card, Popover, code.
Preview
Import
Import
- Files
- scroll-area.tsx, in components/klarhimmel/ui/. With it: theme, utils.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | required | Required: names the region, which is a tab stop so a keyboard can scroll it. |
orientation | 'vertical' | 'horizontal' | 'both' | 'vertical' | Which way it scrolls. Default vertical. Give the height or width with a class (max-h-64). |
children | ReactNode | required | |
native attributes | HTMLAttributes | - | Every native attribute of the element passes through, className included. |
Accessibility
| Key | Does |
|---|---|
Tab | Reaches the region |
Arrow keys | Scroll by a line |
Page Up / Page Down / Space | Scroll by a page |
Home / End | Jump to the start or the end |
The region is named and focusable, so a keyboard can scroll it. The scrollbar is thin but always drawn where the platform allows, and a soft edge shows where there is more.
Accessibility