Skip to content
Klarhimmel UI

Scroll area

  • Room 201, Garden, 1 190 kr
  • Room 202, Garden, 1 190 kr
  • Room 203, Garden, 1 190 kr
  • Room 204, Garden, 1 190 kr
  • Room 205, Garden, 1 190 kr
  • Room 206, Garden, 1 190 kr
  • Room 207, Garden, 1 190 kr
  • Room 208, Garden, 1 190 kr
  • Room 209, Garden, 1 190 kr
  • Room 210, Garden, 1 190 kr
  • Room 211, Garden, 1 190 kr
  • Room 212, Garden, 1 190 kr
  • Room 213, Garden, 1 190 kr
  • Room 214, Garden, 1 190 kr
npx shadcn add @klarhimmel/scroll-area

Examples

  • 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

  • Room 201: Garden, 1190 kr
  • Room 202: Seaside, 1340 kr
  • Room 203: Loft, 1490 kr
  • Room 204: Courtyard, 1640 kr
  • Room 205: Garden, 1790 kr
  • Room 206: Seaside, 1190 kr
  • Room 207: Loft, 1340 kr
  • Room 208: Courtyard, 1490 kr
  • Room 209: Garden, 1640 kr
  • Room 210: Seaside, 1790 kr
  • Room 211: Loft, 1190 kr
  • Room 212: Courtyard, 1340 kr
  • Room 213: Garden, 1490 kr
  • Room 214: Seaside, 1640 kr
  • Room 215: Loft, 1790 kr
  • Room 216: Courtyard, 1190 kr
  • Room 217: Garden, 1340 kr
  • Room 218: Seaside, 1490 kr
  • Room 219: Loft, 1640 kr
  • Room 220: Courtyard, 1790 kr
  • Room 221: Garden, 1190 kr
  • Room 222: Seaside, 1340 kr
  • Room 223: Loft, 1490 kr
  • Room 224: Courtyard, 1640 kr
scroll-area.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { ScrollArea } from '@/components/klarhimmel/ui/scroll-area';

export default function Example() {
  return (
    <Theme theme="brand">
      <ScrollArea aria-label="Rooms and rates" className="max-h-64">
        <ul>
          <li>Room 201, Garden, 1 190 kr</li>
          <li>Room 202, Seaside, 1 340 kr</li>
          <li>Room 203, Loft, 1 490 kr</li>
        </ul>
      </ScrollArea>
    </Theme>
  );
}

Import

Import

import { ScrollArea } from '@/components/klarhimmel/ui/scroll-area';
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

PropTypeDefaultDescription
aria-labelstringrequiredRequired: 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).
childrenReactNoderequired
native attributesHTMLAttributes-Every native attribute of the element passes through, className included.

Accessibility

KeyDoes
TabReaches the region
Arrow keysScroll by a line
Page Up / Page Down / SpaceScroll by a page
Home / EndJump 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