Skip to content

Scroll area

A box of fixed height whose content scrolls inside it, with a thin scrollbar that keeps contrast.

<div class="cap-scroll-area" id="sa-rest" tabindex="0" role="region" aria-label="Sample excerpt" style="--scroll-area-max: 10rem">
  <p>The spring survey covered twelve sites along the creek, each visited once a week from March to May.</p>
  <p>Counts rose through April and fell in the first week of May, when the water was highest.</p>
  <p>Two sites were dry for most of March and are left out of the totals.</p>
  <p>The full counts, by site and by week, are in the annual report.</p>
  <p>Next season adds three sites upstream and moves the visits to Tuesdays.</p>
</div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/scroll-area.css";

Usage

<div class="cap-scroll-area" tabindex="0" role="region" aria-label="Sample manuscript">…</div>

Examples

No frame

<div class="cap-scroll-area" data-frame="none" tabindex="0" role="region" aria-label="Release notes" style="--scroll-area-max: 6rem">
  <p>Added the card, the carousel and the marquee.</p>
  <p>Fixed the header's border when stuck.</p>
  <p>Removed the old scrollbar rules.</p>
  <p>Updated the docs.</p>
</div>

API reference

CSS variables

VariableDefault
--scroll-area-max24rem
--scrollbar-thumbvar(--muted)
--scrollbar-trackvar(--sunken)

Parts and data attributes

ClassIs
.cap-scroll-areathe root
AttributeValues
data-framenone

Accessibility

KeyDoes
TabReaches the area (skip tabindex only when something inside it already takes focus)
Arrow keys, Page Up, Page Down, Home, EndScroll it