# Sticky Scroll Reveal

> Sections of text scroll past while a pinned visual changes to match.

Source: https://www.honestui.com/docs/animated/sticky-scroll-reveal

```tsx
"use client";

import { useRef } from "react";

import { StickyScrollReveal, type StickyScrollSection } from "@/registry/default/animated/sticky-scroll-reveal";

function FilterVisual() {
  return (
    <div className="grid place-items-center p-5">
      <div className="w-full max-w-64 rounded-xl border border-border bg-background p-3 shadow-sm">
        <div className="flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-xs text-muted-foreground">
          <span className="size-3 rounded-full border border-muted-foreground/60" />
          Status is active
        </div>
        <div className="mt-3 flex flex-wrap gap-1.5">
          {["Active", "Admin", "Last 30 days"].map((chip) => (
            <span key={chip} className="rounded-full bg-muted px-2.5 py-1 text-[11px] font-medium text-foreground">
              {chip}
            </span>
          ))}
        </div>
      </div>
    </div>
  );
}

function ChartVisual() {
  const bars = [42, 58, 51, 66, 0, 0, 74, 69];
  return (
    <div className="flex items-end justify-center gap-1.5 p-6 pb-8">
      {bars.map((value, i) =>
        value === 0 ? (
          <span key={i} className="h-24 w-4 rounded-md border border-dashed border-muted-foreground/40" />
        ) : (
          <span
            key={i}
            className="w-4 rounded-md bg-foreground/80"
            style={{ height: `${Math.round(value * 1.6)}px`, opacity: i === bars.length - 1 ? 0.45 : 1 }}
          />
        ),
      )}
    </div>
  );
}

function KeyboardVisual() {
  return (
    <div className="grid place-items-center gap-3 p-6">
      <div className="flex gap-2">
        {["⌘", "K"].map((key) => (
          <kbd
            key={key}
            className="grid size-14 place-items-center rounded-xl border border-border bg-background font-sans text-xl text-foreground shadow-[0_2px_0_var(--border)]"
          >
            {key}
          </kbd>
        ))}
      </div>
      <span className="text-xs text-muted-foreground">Every action has a shortcut</span>
    </div>
  );
}

function ChecklistVisual() {
  return (
    <div className="grid place-items-center p-6">
      <ul className="w-full max-w-60 space-y-2.5">
        {["Labels and roles", "Visible focus", "Reduced motion", "Screen reader status"].map((item) => (
          <li key={item} className="flex items-center gap-2.5 text-sm text-foreground">
            <span className="grid size-5 place-items-center rounded-full bg-foreground text-[11px] text-background">
              ✓
            </span>
            {item}
          </li>
        ))}
      </ul>
    </div>
  );
}

const SECTIONS: StickyScrollSection[] = [
  {
    title: "Filters people can read",
    body: "Every filter reads as a sentence, so anyone can see what the table is showing and why.",
    visual: <FilterVisual />,
  },
  {
    title: "Charts that admit gaps",
    body: "Missing days stay missing and an open month is marked as in progress, instead of a fake drop.",
    visual: <ChartVisual />,
  },
  {
    title: "Keyboard first",
    body: "Command menus, shortcuts, and focus that always lands somewhere sensible.",
    visual: <KeyboardVisual />,
  },
  {
    title: "Accessible by default",
    body: "Roles, labels, and live status ship with each component, not as a ticket for later.",
    visual: <ChecklistVisual />,
  },
];

export function StickyScrollRevealDemo() {
  const scrollRef = useRef<HTMLDivElement>(null);
  return (
    <div
      ref={scrollRef}
      role="region"
      tabIndex={0}
      aria-label="Product features"
      className="h-[440px] w-full max-w-3xl overflow-y-auto rounded-xl px-4 outline-none focus-visible:ring-2 focus-visible:ring-ring"
    >
      <StickyScrollReveal sections={SECTIONS} scrollContainer={scrollRef} headingAs="h2" className="pb-24" />
    </div>
  );
}

```

## Overview [#overview]

Sticky Scroll Reveal pairs a column of short sections with a visual that stays pinned beside them. As each section reaches the middle of the scroll area, the visual crossfades to that section's image or illustration, the section's text comes forward, and a thin rail beside it lights up.

Use it on a feature or product page to walk through three to six ideas, each with one visual. The text carries the content; the pinned visual supports it.

When the component is narrower than about 32rem, it switches to a single column and each section shows its own visual inline under the text, so nothing depends on scrolling past a pinned panel.

## Installation [#installation]

<CliBlock commands="[&#x22;sticky-scroll-reveal&#x22;]" />

## Usage [#usage]

```tsx
import { StickyScrollReveal } from "@/components/animated/sticky-scroll-reveal"

const sections = [
  { title: "Filters people can read", body: "…", visual: <FilterPreview /> },
  { title: "Charts that admit gaps", body: "…", visual: <ChartPreview /> },
  { title: "Keyboard first", body: "…", visual: <ShortcutPreview /> },
]

<StickyScrollReveal sections={sections} />
```

By default it follows the page scroll. When it sits inside a box that scrolls on its own, pass that box as `scrollContainer`:

```tsx
const scrollRef = useRef<HTMLDivElement>(null)

<div ref={scrollRef} className="h-[480px] overflow-y-auto">
  <StickyScrollReveal sections={sections} scrollContainer={scrollRef} />
</div>
```

Set `side="left"` to pin the visual on the left, and `stickyTop` to clear a fixed header.

## Accessibility [#accessibility]

Sections stay in reading order, and each section's text is always in the document; only its visual emphasis changes. The active section has `aria-current="step"`.

Visuals are decorative by default and hidden from assistive technology. When a visual carries information, give the section a `visualLabel` and it is exposed as an image with that name. Only the visible copy of each visual is exposed: the pinned panel on wide layouts, the inline one on narrow layouts.

With reduced motion, the visual swaps instantly, with no fade, scale, or blur.

## API Reference [#api-reference]


  ### `sections`

type: `StickyScrollSection[]`

Each section's 

    `title`

    , 

    `body`

    , 

    `visual`

    , and optional 

    `id`

     and 

    `visualLabel`

    .

  ### `scrollContainer`



">
    The element that scrolls, when it is not the page.

  ### `side`

type: `&#x22;left&#x22; | &#x22;right&#x22;` · default: `&#x22;right&#x22;`

Which side the pinned visual sits on.

  ### `stickyTop`

type: `number | string` · default: `&#x22;1.5rem&#x22;`

Distance from the top of the scroll area where the visual pins.

  ### `headingAs`

type: `&#x22;h2&#x22; | &#x22;h3&#x22; | &#x22;h4&#x22;` · default: `&#x22;h3&#x22;`

Heading element for each section title, to fit the page outline.

  ### `rail`

type: `boolean` · default: `true`

Shows a rail beside each section that lights up while it is active.

  ### `onActiveChange`



void">
    Called with the index of the section that becomes active.

  ### `className`

type: `string`

Class for the root element.

  ### `sectionClassName`

type: `string`

Class for each section's text block.

  ### `visualClassName`

type: `string`

Class for the visual panel.
