Skip to content
VinUIComponentsScroll Area

Scroll Area

A box that scrolls its content, with thin scrollbars in the colours of the style. It is the browser's own scrolling, so touch, wheel, keyboard and find-in-page all work. Same markup and props in every style: switch the style in the header to see it change.

Vertical

A fixed-height list that scrolls up and down. Click it or Tab to it, then use the arrow keys, Page Up/Down, Home and End.

Releases

v2.4.0

v2.3.1

v2.3.0

v2.2.0

v2.1.2

v2.1.1

v2.1.0

v2.0.0

v1.9.0

v1.8.0
scroll-area-vertical.html
<div class="vin-scroll-area" role="region" aria-label="Releases" tabindex="0" style="width: 100%; max-width: 240px; height: 220px">
  <div style="padding: 12px 16px">
    <p style="margin: 0 0 8px; font-weight: 600">Releases</p>
    <div style="padding: 6px 0">v2.4.0</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v2.3.1</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v2.3.0</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v2.2.0</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v2.1.2</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v2.1.1</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v2.1.0</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v2.0.0</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v1.9.0</div>
    <hr class="vin-separator">
    <div style="padding: 6px 0">v1.8.0</div>
  </div>
</div>

Horizontal

A row wider than its box, like a shelf of cards. Shift + wheel, a trackpad swipe or the arrow keys scroll it sideways.

Morning focus
24 tracks
Deep work
18 tracks
Late night
31 tracks
Road trip
42 tracks
Sunday
15 tracks
scroll-area-horizontal.html
<div class="vin-scroll-area vin-scroll-area--horizontal" role="region" aria-label="Playlists" tabindex="0" style="width: 100%; max-width: 400px">
  <div style="display: flex; gap: 12px; width: max-content; padding: 16px">
    <figure style="margin: 0; width: 120px">
      <div style="aspect-ratio: 1; border-radius: var(--vin-radius); background: linear-gradient(135deg, var(--vin-accent), color-mix(in srgb, var(--vin-accent) 35%, var(--vin-surface)))"></div>
      <figcaption style="margin-top: 8px">Morning focus<br><span style="color: var(--vin-muted)">24 tracks</span></figcaption>
    </figure>
    <figure style="margin: 0; width: 120px">
      <div style="aspect-ratio: 1; border-radius: var(--vin-radius); background: linear-gradient(200deg, color-mix(in srgb, var(--vin-accent) 70%, var(--vin-fg)), color-mix(in srgb, var(--vin-accent) 45%, var(--vin-surface)))"></div>
      <figcaption style="margin-top: 8px">Deep work<br><span style="color: var(--vin-muted)">18 tracks</span></figcaption>
    </figure>
    <figure style="margin: 0; width: 120px">
      <div style="aspect-ratio: 1; border-radius: var(--vin-radius); background: linear-gradient(45deg, color-mix(in srgb, var(--vin-accent) 25%, var(--vin-surface)), var(--vin-accent))"></div>
      <figcaption style="margin-top: 8px">Late night<br><span style="color: var(--vin-muted)">31 tracks</span></figcaption>
    </figure>
    <figure style="margin: 0; width: 120px">
      <div style="aspect-ratio: 1; border-radius: var(--vin-radius); background: linear-gradient(160deg, color-mix(in srgb, var(--vin-accent) 55%, var(--vin-surface)), color-mix(in srgb, var(--vin-accent) 80%, var(--vin-fg)))"></div>
      <figcaption style="margin-top: 8px">Road trip<br><span style="color: var(--vin-muted)">42 tracks</span></figcaption>
    </figure>
    <figure style="margin: 0; width: 120px">
      <div style="aspect-ratio: 1; border-radius: var(--vin-radius); background: linear-gradient(90deg, var(--vin-accent), color-mix(in srgb, var(--vin-accent) 20%, var(--vin-surface)))"></div>
      <figcaption style="margin-top: 8px">Sunday<br><span style="color: var(--vin-muted)">15 tracks</span></figcaption>
    </figure>
  </div>
</div>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add scroll-area
React
import { ScrollArea } from "@/components/vin/scroll-area";
Vue
import ScrollArea from "@/components/vin/scroll-area.vue";
Svelte
import ScrollArea from "$lib/components/vin/scroll-area.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/scroll-area.json, which every framework version is tested against.

PropValuesDefaultIn HTML
orientation
Which way the content scrolls.
verticalhorizontalbothverticalvin-scroll-area--horizontal / vin-scroll-area--both
label
A name for the region, read by screen readers. Needed when nothing inside can take focus, so the box itself is in the Tab order.
string—role="region" aria-label="…" tabindex="0"
children
The content. Give the box a height (or a width) so it has something to scroll.
ReactNode—the content of div.vin-scroll-area

Parts

React, Vue, SvelteHTML classes
<ScrollArea>.vin-scroll-area.vin-scroll-area--horizontal.vin-scroll-area--both

Accessibility

  • It is native scrolling: nothing is faked, so the wheel, touch, the keyboard and assistive technology work as on any page.
  • The box has tabindex="0", so keyboard users can focus it and scroll with the arrow keys, Page Up/Down and Home/End. A focus ring shows when it has focus.
  • Because it can take focus, it has a name: role="region" with an aria-label (React: label) that says what is inside.
  • Scrollbars are thin, but they stay visible and draggable, in the style's colours.