Skip to content

Scroll area ​

A scrollable region with thin, theme-aware scrollbars that keyboard users can reach and scroll.

Installation ​

bash
npx bootcn add scroll-area
bash
pnpm dlx bootcn add scroll-area
bash
yarn dlx bootcn add scroll-area
bash
bunx --bun bootcn add scroll-area

The CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.

Usage ​

Give the area a height (or max-height) and put any content inside. For a horizontal strip, give it a width and let the content be wider.

Accessibility ​

  • tabindex="0" lets keyboard users focus the area and scroll it with the arrow keys; a <section> with aria-label makes it a named region.
  • Scrollbars stay visible and use theme colors in both modes.

Dependencies ​

  • Bootstrap 5.3+ CSS.
  • themes/tokens/tokens.css.

Source ​

The exact files the CLI installs (scroll-area@1.0.0). View on GitHub · Report an issue

html
<section
  class="bootcn-scroll-area"
  style="height: 16rem; max-width: 14rem"
  tabindex="0"
  aria-label="Release tags"
>
  <p class="bootcn-scroll-area__heading">Tags</p>
  <ul class="bootcn-scroll-area__list">
    <li>v1.40.0</li>
    <li>v1.39.0</li>
    <li>v1.38.0</li>
    <li>v1.37.0</li>
    <li>v1.36.0</li>
    <li>v1.35.0</li>
    <li>v1.34.0</li>
    <li>v1.33.0</li>
    <li>v1.32.0</li>
    <li>v1.31.0</li>
    <li>v1.30.0</li>
    <li>v1.29.0</li>
    <li>v1.28.0</li>
    <li>v1.27.0</li>
    <li>v1.26.0</li>
    <li>v1.25.0</li>
    <li>v1.24.0</li>
    <li>v1.23.0</li>
    <li>v1.22.0</li>
    <li>v1.21.0</li>
    <li>v1.20.0</li>
    <li>v1.19.0</li>
    <li>v1.18.0</li>
    <li>v1.17.0</li>
    <li>v1.16.0</li>
    <li>v1.15.0</li>
    <li>v1.14.0</li>
    <li>v1.13.0</li>
    <li>v1.12.0</li>
    <li>v1.11.0</li>
  </ul>
</section>
css
.bootcn-scroll-area {
  overflow: auto;
  padding: 1rem;
  border: var(--bootcn-border-width) solid var(--bootcn-border-color);
  border-radius: var(--bootcn-radius-lg);
  scrollbar-color: var(--bootcn-border-color) transparent;
  scrollbar-width: thin;
}

.bootcn-scroll-area:focus-visible {
  outline: 0;
  box-shadow: var(--bootcn-focus-ring);
}

.bootcn-scroll-area::-webkit-scrollbar {
  width: 0.625rem;
  height: 0.625rem;
}

.bootcn-scroll-area::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 9999px;
  background-color: var(--bootcn-border-color);
  background-clip: padding-box;
}

.bootcn-scroll-area__heading {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.bootcn-scroll-area__list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.bootcn-scroll-area__list > li {
  padding: 0.5rem 0;
  border-top: var(--bootcn-border-width) solid var(--bootcn-border-color);
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.