Skip to content
Pebble Pro is here at $49 one timeSee what’s included ↗
Pebble
ComponentsDocsMCPPricing
⌕ Find a component↗Log in
All components 673

Categories

Core inputs & forms46Buttons & actions33Navigation36Overlays & feedback49Data display33Charts & data viz40Cards & layout43Marketing blocks38App shells & pages37AI interfaces40Text & typography effects33Backgrounds & visual effects38Motion & transitions32Numbers & counters32Media34E-commerce333D & interactive36Themed sets40
Start with the essentials.Installation guide ↗Connect your agent ↗
← All componentsCards & layout

Scroll Area

A scroll container with thin themed scrollbars and a keyboard-focusable viewport.

Preview

# plot-updates

2
  • PR
    Priya Raman14:22

    Soil pH back from the lab: 6.4 on C-11.

  • MO
    Malik Okoye13:57

    Ridge photos are up, 38 in the shared folder.

  • IA
    Ines Alvarez12:40

    Moved Thursday's walk to 09:30.

  • TF
    Tomás Ferreira11:18

    Two new members signed the plot agreement.

  • PR
    Priya Raman10:02

    Can someone check the east water butt?

  • MO
    Malik Okoye09:41

    Compost delivery confirmed for Friday.

  • IA
    Ines AlvarezYesterday

    Draft rota for November is in the doc.

  • TF
    Tomás FerreiraYesterday

    Gate code changes on the 10th.

  • PR
    Priya RamanMon

    Seed swap raised $214 for the shed fund.

Shared files

6 files · 3.5 MB
  • Ridge survey.pdf

    2.4 MB

  • Plot map.svg

    184 KB

  • Yields 2026.csv

    36 KB

  • Rota draft.pdf

    820 KB

  • Water use.csv

    12 KB

  • Shed plan.svg

    96 KB

Drag the bar, use Shift + wheel or focus the strip and press the arrow keys.

Install

Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.

npx shadcn@latest add https://pebbleui.com/r/scroll-area.json

Props

PropTypeDefaultDescription
scrollbars"vertical" | "horizontal" | "both""vertical"Which scrollbars ScrollArea renders; the corner is added for both.
fadebooleanfalseFade the content out at an edge that has more to scroll. Follows the horizontal axis when scrollbars is horizontal.
type"auto" | "always" | "scroll" | "hover""hover"When the scrollbars are visible.
scrollHideDelaynumber600Milliseconds before scrollbars hide (hover and scroll types).
aria-labelstring-Names the viewport, which then becomes role=region. aria-labelledby works the same way.
orientation"vertical" | "horizontal""vertical"ScrollBar: which axis the bar controls.
classNamestring-Root and ScrollBar; wins over the defaults. Size the area here (for example h-72).
Build notes
Built on the Radix ScrollArea primitive. The Viewport is a native overflow
container whose own scrollbars Radix hides with injected CSS; Radix measures
viewport and content sizes (ResizeObserver) and renders absolutely positioned
`Scrollbar` tracks with a `Thumb` sized to the visible ratio and translated to
the scroll offset. Dragging the thumb or clicking the track scrolls the
viewport. The root is `relative overflow-hidden`; the viewport is
`size-full rounded-[inherit]` so it fills the box and inherits its corners.
Bars are 10 px (`w-2.5`/`h-2.5`) with 1 px padding and a transparent border
on the inner edge, so the thumb sits off the content. The thumb is
`bg-muted-foreground/40` (60% on hover) so it reads on both card and page
backgrounds, `CanvasText` in forced colors. Radix mounts the thumb only after
it has measured overflow. Differences from the source: a `scrollbars` prop
instead of nesting a horizontal `ScrollBar` inside the content, the viewport is
focusable and labelable, an opaque `ring` focus style, and a stronger thumb
than the `border` colour.

**Pebble (2026-11-03).** The bar is a `group/scrollbar` rail with `p-[3px]`
that widens on hover (`w-2.5 → w-3.5`, `h-2.5 → h-3.5`) and takes a
`bg-muted/70` track, with a motion-safe `duration-(--motion-fast) ease-enter`
transition. The thumb is `bg-muted-foreground/35`, `/60` on bar hover and
`/75` while dragged, and its `before:` pseudo-element is at least 32 px along
the bar's long axis (`min-h-8` vertical, `min-w-8` horizontal) so it is easy
to grab without widening the bar across. Focus is an inset 2 px `ring`-colour
outline on the root's `::after`, outside the viewport's mask and stacked over
the bars. New
optional `fade`: an effect measures the viewport on scroll and with a
ResizeObserver, and applies an inline `mask-image` linear gradient that
fades 1.5 rem at whichever edge has more to scroll. It starts with no fade so
the server render matches, and as an alpha mask it works on any surface
colour. The demo shows a chat channel with a vertical fade and unread ember
dots, and a horizontal file strip in a recessed well with drawn SVG
thumbnails.

<!-- PEBBLE-LICENSE -->
View source

registry/layout/scroll-area/scroll-area.tsx

"use client";

/* PEBBLE-LICENSE
Built by Pebble. Component: scroll-area.

First-party license: MIT

The following first-party terms apply only to original Pebble material.

MIT License

Copyright (c) 2026 Praxys Solutions LLC (Pebble)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

THIRD-PARTY NOTICES
These notices apply to identified upstream portions; Pebble terms do not replace or narrow their rights.

Upstream: https://raw.githubusercontent.com/shadcn-ui/ui/main/LICENSE.md
MIT License

Copyright (c) 2023 shadcn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */

import * as React from "react";
import { ScrollArea as ScrollAreaPrimitive } from "radix-ui";

import { cn } from "@/lib/utils";

export type ScrollAreaProps = React.ComponentProps<typeof ScrollAreaPrimitive.Root> & {
  /** Which custom scrollbars to render. */
  scrollbars?: "vertical" | "horizontal" | "both";
  /**
   * Fade the content out at an edge that has more to scroll, so the overflow
   * is visible before the user scrolls. Follows the vertical axis, or the
   * horizontal one when `scrollbars="horizontal"`.
   */
  fade?: boolean;
};

const FADE = "1.5rem";

export function ScrollArea({
  scrollbars = "vertical",
  fade = false,
  className,
  children,
  "aria-label": ariaLabel,
  "aria-labelledby": ariaLabelledBy,
  ...props
}: ScrollAreaProps) {
  const labelled = ariaLabel !== undefined || ariaLabelledBy !== undefined;
  const viewport = React.useRef<HTMLDivElement>(null);
  const horizontal = scrollbars === "horizontal";
  // Which edges have more content beyond them. Starts with none, so the
  // server render and first paint are the plain list; measured after mount.
  const [edges, setEdges] = React.useState({ start: false, end: false });

  React.useEffect(() => {
    const el = viewport.current;
    if (!fade || !el) return;
    const measure = () => {
      const pos = horizontal ? el.scrollLeft : el.scrollTop;
      const max = horizontal ? el.scrollWidth - el.clientWidth : el.scrollHeight - el.clientHeight;
      const start = pos > 1;
      const end = pos < max - 1;
      setEdges((prev) => (prev.start === start && prev.end === end ? prev : { start, end }));
    };
    measure();
    el.addEventListener("scroll", measure, { passive: true });
    const ro = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(measure);
    ro?.observe(el);
    if (el.firstElementChild) ro?.observe(el.firstElementChild);
    return () => {
      el.removeEventListener("scroll", measure);
      ro?.disconnect();
    };
  }, [fade, horizontal]);

  const mask = fade
    ? `linear-gradient(to ${horizontal ? "right" : "bottom"}, transparent 0, black ${
        edges.start ? FADE : "0px"
      }, black calc(100% - ${edges.end ? FADE : "0px"}), transparent 100%)`
    : undefined;

  return (
    <ScrollAreaPrimitive.Root
      data-slot="scroll-area"
      className={cn(
        "relative overflow-hidden",
        // The focus ring lives on the root, outside the viewport's fade mask,
        // drawn by a pseudo-element stacked over the z-10 scrollbars so a
        // hovered bar's fill cannot cover it. An outline survives forced
        // colors. Only the own viewport counts, not a focused child or a
        // nested scroll area.
        "after:pointer-events-none after:absolute after:inset-0 after:z-20 after:rounded-[inherit]",
        "has-[>[data-slot=scroll-area-viewport]:focus-visible]:after:outline-2 has-[>[data-slot=scroll-area-viewport]:focus-visible]:after:-outline-offset-2 has-[>[data-slot=scroll-area-viewport]:focus-visible]:after:outline-ring",
        className,
      )}
      {...props}
    >
      <ScrollAreaPrimitive.Viewport
        ref={viewport}
        data-slot="scroll-area-viewport"
        data-fade-start={fade ? edges.start : undefined}
        data-fade-end={fade ? edges.end : undefined}
        // Focusable so keyboard users can scroll it with arrow keys and Page
        // Up/Down. A label turns it into a named region landmark.
        tabIndex={0}
        role={labelled ? "region" : undefined}
        aria-label={ariaLabel}
        aria-labelledby={ariaLabelledBy}
        // The fade is an alpha mask, not a colour, so it works on any surface.
        style={mask ? { maskImage: mask, WebkitMaskImage: mask } : undefined}
        className="size-full rounded-[inherit] outline-none"
      >
        {children}
      </ScrollAreaPrimitive.Viewport>
      {scrollbars !== "horizontal" && <ScrollBar orientation="vertical" />}
      {scrollbars !== "vertical" && <ScrollBar orientation="horizontal" />}
      {scrollbars === "both" && <ScrollAreaPrimitive.Corner data-slot="scroll-area-corner" />}
    </ScrollAreaPrimitive.Root>
  );
}

export function ScrollBar({
  orientation = "vertical",
  className,
  ...props
}: React.ComponentProps<typeof ScrollAreaPrimitive.Scrollbar>) {
  return (
    <ScrollAreaPrimitive.Scrollbar
      data-slot="scroll-area-scrollbar"
      orientation={orientation}
      className={cn(
        // A slim rail that widens and takes a recessed track on hover or drag,
        // so it is easy to grab without crowding the content at rest.
        "group/scrollbar z-10 flex touch-none p-[3px] select-none",
        "hover:bg-muted/70 active:bg-muted/70",
        "motion-safe:transition-[background-color,width,height] motion-safe:duration-(--motion-fast) motion-safe:ease-enter",
        orientation === "vertical" && "h-full w-2.5 hover:w-3.5",
        orientation === "horizontal" && "h-2.5 flex-col hover:h-3.5",
        className,
      )}
      {...props}
    >
      <ScrollAreaPrimitive.Thumb
        data-slot="scroll-area-thumb"
        className={cn(
          "relative flex-1 rounded-full bg-muted-foreground/35",
          "group-hover/scrollbar:bg-muted-foreground/60 active:bg-muted-foreground/75",
          "motion-safe:transition-colors motion-safe:duration-(--motion-fast)",
          // Grow the hit area beyond the visible thumb for touch and mice, along
          // the bar only, so it never reaches across into the content.
          "before:absolute before:top-1/2 before:left-1/2 before:size-full before:-translate-1/2 before:content-['']",
          "group-data-[orientation=horizontal]/scrollbar:before:min-w-8 group-data-[orientation=vertical]/scrollbar:before:min-h-8",
          "forced-colors:bg-[CanvasText]",
        )}
      />
    </ScrollAreaPrimitive.Scrollbar>
  );
}
Pebble

Small details.
Better interfaces.

React components to explore, make your own, and build on.

Library

  • Components
  • Installation
  • Pricing

Resources

  • For agents
  • About
  • Support

Legal

  • License
  • Terms
  • Privacy
  • Final sale

Built by Pebble

A product of Praxys Solutions LLC ↗

Pebble Pro is live

$49 one time, lifetime updates ↗