Components
Layout & Primitives
Scroll Area

Scroll Area

Use ScrollArea to build consistent, accessible interfaces aligned with the shared design system.

Installation

1. Copy the source code:

  • Source in this monorepo: packages/ui/src/components/scroll-area.tsx
  • Place in your project: components/ui/scroll-area.tsx
  • Required utility: lib/utils.ts (for cn helper)

2. Update the import paths to match your project structure.


Usage

import { ScrollArea } from "@hoag/ui/components/scroll-area";
 
export default function Demo() {
  return (
    <ScrollArea className="h-56 w-72 rounded-md border">
      <div className="space-y-2 p-4">
        {Array.from({ length: 12 }).map((_, index) => (
          <div key={index} className="rounded-md border px-3 py-2 text-sm">
            Activity item {index + 1}
          </div>
        ))}
      </div>
    </ScrollArea>
  );
}

Import

import { ScrollArea, ScrollBar } from "@hoag/ui/components/scroll-area";

Basic Example

Activity item 1
Activity item 2
Activity item 3
Activity item 4
Activity item 5
Activity item 6
Activity item 7
Activity item 8
Activity item 9
Activity item 10
Activity item 11
Activity item 12
import { ScrollArea } from "@hoag/ui/components/scroll-area";
 
export function ScrollAreaBasicExample() {
  return (
    <ScrollArea className="h-56 w-72 rounded-md border">
      <div className="space-y-2 p-4">
        {Array.from({ length: 12 }).map((_, index) => (
          <div key={index} className="rounded-md border px-3 py-2 text-sm">
            Activity item {index + 1}
          </div>
        ))}
      </div>
    </ScrollArea>
  );
}

Composition Pattern

import { ScrollArea } from "@hoag/ui/components/scroll-area";
 
export function ScrollAreaSection() {
  return (
    <section className="space-y-3">
      <h3 className="text-sm font-medium">Scroll Area section</h3>
      <ScrollArea />
    </section>
  );
}

Accessibility Checklist

  • Verify semantic roles and ARIA attributes for interactive behavior.
  • Keep keyboard navigation and focus visibility consistent in all states.
  • Ensure color contrast meets accessibility requirements in light and dark themes.
  • Provide screen reader context for dynamic state or content changes.

Testing Checklist

  • Add render tests for default and key variant states.
  • Add interaction tests for callbacks and state transitions.
  • Add visual regression checks for responsive and theme variations.
  • Cover edge states such as loading, empty, disabled, and error.

Production Tips

  • Wrap component logic in feature-level abstractions for domain behavior.
  • Keep visual variants centralized to avoid style drift across screens.
  • Reuse a single import path strategy for simpler refactors.
  • Mirror documented states in Storybook and QA checklists.

Named Exports

  • ScrollArea
  • ScrollBar

API Reference

For authoritative prop signatures and implementation details, inspect:

  • packages/ui/src/components/scroll-area.tsx

MIT 2026 © @hoag/ui