Skip to content

GhostScrollArea ​

GhostScrollArea is a bounded native overflow container. Import it from @ghostvue/themes for scrollbar containment and token-colored native scrollbars. The themed wrapper adds styling only: overflow measurement, focus, and naming come from the headless component in @ghostvue/vue. To style the region yourself or bind the contract to your own element, see Advanced: headless composition.

Workspace activity feed ​

Workspace activity feed

Named scroll region inside a card displaying timestamped team events with responsive metadata.

Workspace activity6 events
  • AL
    Ada LovelacePublished @ghostvue/themes v2.14.0
    Release10:42
  • GH
    Grace HopperUpdated contrast tokens for dark surface elevation
    Tokens10:18
  • AT
    Alan TuringVerified Linux visual baselines across 17 showcases
    QA09:54
  • KJ
    Katherine JohnsonRotated staging deploy key for us-west-2
    Security09:12
  • MH
    Margaret HamiltonEnabled automatic rollback guard on canary cluster
    Infra08:40
  • BL
    Barbara LiskovArchived legacy icon sprite pipeline
    Cleanup08:05

A bounded GhostScrollArea inside a GhostCard keeps a fixed height while scrolling through deterministic activity entries. Because there are no focusable controls inside, label names the region (role="region" + aria-label) so keyboard users can focus and scroll it.

Horizontal strip ​

Horizontal strip

Named horizontal region inside a card that scrolls a row of deployment environment tiles.

Deployment environments6 environments
  • Productionus-east-1v2.14.0Healthy
  • Canaryus-east-1v2.15.0-rc.2Rolling out
  • Stagingus-west-2v2.15.0-rc.2Healthy
  • EU mirroreu-central-1v2.13.4Degraded
  • QAus-west-2v2.15.0-rc.3Deploying
  • Preview 482us-west-2pr-482Idle

Set orientation="horizontal" when a row of items is wider than its card. Each environment tile is at most 85% of the region's width, so a phone shows one whole tile with the next one peeking in, and the rest scroll on the inline axis inside the region. The page itself never scrolls sideways. Tab to the Deployment environments region, then press the left and right arrow keys to scroll to the last tile. Use orientation="both" for content that is wide and tall, such as a table preview.

Size the region ​

Themed

Inbox region sized by its layout, with native scrollbar containment on @ghostvue/themes.

  • BillingInvoice INV-2048 is ready
  • Ada LovelaceReview requested on the tokens PR
  • StatusScheduled maintenance on Saturday
  • Grace HopperRelease notes draft for v2.15
  • SecurityNew sign-in from Berlin
  • Alan TuringVisual baselines updated
  • SupportTicket 3141 was resolved
  • Margaret HamiltonCanary rollback guard enabled

The component never picks a size. Set a block-size constraint for vertical overflow, or an inline-size constraint for horizontal overflow, on the root (style, class) or through the layout parent. The root applies native overflow-y: auto by default and exposes data-overflow when content exceeds the box. The themed wrapper adds data-themed, overscroll-behavior: contain, and scrollbar-color where the engine supports it.

Scrollbar clearance ​

The themed wrapper keeps content clear of the scrollbar. Overlay scrollbars (macOS, iOS, Android) draw on top of the content and ignore scrollbar-gutter, so the root reserves --ghost-space-inset-scrollbar on the side where each scrollbar sits:

orientationReserved space
verticalpadding-inline-end
horizontalpadding-block-end
bothpadding-inline-end and padding-block-end

The space is there whether or not the content overflows, so nothing moves when the scrollbar appears. Classic scrollbars take their own track next to the padding, and type="scroll" also reserves that track with scrollbar-gutter: stable. Logical properties keep the space on the scrollbar side in right-to-left layouts. Do not add your own padding for the scrollbar. If you set padding on the root, your value replaces the reserved space, so include var(--ghost-space-inset-scrollbar) on those edges.

Stick to bottom ​

Stick to bottom

Build output that follows new lines, pauses when the reader scrolls up, and returns with a Jump to latest button bound to v-model:stuck.

Following output
  1. $ pnpm build
  2. > ghostvue-workspace@0.0.0 build
  3. > pnpm build:packages && pnpm --filter @ghostvue/playground build
  4. Scope: 9 of 10 workspace projects
  5. packages/vue build$ vite build
  6. packages/vue build: transforming...
  7. packages/vue build: 412 modules transformed.
  8. packages/vue build: dist/index.js 182.40 kB
  9. packages/themes build$ node scripts/compile-tokens.mjs
  10. packages/themes build: wrote 3 palettes

Set stick-to-bottom on a log, build output, or chat so the view follows new content while the reader is at the bottom. Press Run build, then scroll up with the wheel, a scrollbar drag, a touch drag, or ArrowUp / PageUp / Home on the focused region: following stops at once and later lines arrive below the view without pulling the reader back. Scrolling back to the bottom (or pressing End) resumes following.

  • v-model:stuck is true while the view follows and false after the reader scrolls up. Bind it to show a "Jump to latest" button, as above. Setting it to true scrolls to the bottom instantly and resumes following; setting it to false stops following and leaves the position alone. Omit it for uncontrolled mode, which starts true. A parent that ignores update:stuck(false) keeps the view following, so the reader's next scroll is undone by the next content change. Only do that on purpose, for example for a kiosk log.
  • scrollToBottom(options?) on a template ref scrolls to the bottom and resumes following. { behavior: 'smooth' } animates, except under prefers-reduced-motion: reduce. It also works without stickToBottom.
  • Following is always instant and ignores scroll-behavior: smooth on the root. It never moves focus, never changes the selection, and adds no live region. Announcing new messages is up to you; the chat recipe shows the pattern.
  • Focus and pointers win. A keyboard-focused control inside the log is never scrolled out of view: following stops instead. While a mouse button or finger is down inside the log, following pauses, so a click lands on what you pressed; it catches up when you let go.
  • Keep one growing child. Put the content in one direct element child, such as the example's <ol>, so growth is followed before the next paint. Text placed directly in the root is still followed, one frame later.
  • data-stuck ("true" or "false") is on the root only while stickToBottom is active. stickToBottom applies to vertical and both; with horizontal it is ignored and a development warning (GHOST028) is logged.

With server rendering, the HTML first paints at the top of the content and jumps to the bottom when the component hydrates, because the server cannot set a scroll position. Render the log on the client only if that jump is not acceptable. For a full chat view with message bubbles, a composer, and announcements, see GhostChatMessage.

When native scrolling is enough ​

GhostScrollArea is native scrolling with the bookkeeping done for you. It measures overflow and makes the root a named tab stop only while content overflows and nothing inside can take focus. A plain element with overflow: auto is enough when:

  • The content has its own controls. Links, buttons, and fields inside the box are reachable with Tab, and the browser scrolls each one into view when it gains focus. GhostScrollArea also leaves its root out of the tab order in this case.
  • Nothing is clipped. Content that can grow with the page, or wrap to the available width, does not need a scroll region at all. Prefer wrapping to sideways scrolling for text.

Reach for GhostScrollArea when the overflow depends on data or viewport size and the content is static text or media, as in the examples above.

API ​

PropTypeDefaultDescription
as'div'"div"Scroll root host. Closed union; only div is supported initially.
labelstring—When the root is a tab stop with no inner focusables, sets role=region and aria-label.
orientationGhostScrollAreaOrientation"vertical"Which axes may scroll when content exceeds the box.
stickToBottombooleanfalseFollow new content at the bottom while the reader is at the bottom, and stop following when the reader scrolls up. Applies to vertical and both; ignored with a development warning for horizontal.
stuckboolean—Whether the view is following new content (v-model:stuck). Omit for uncontrolled mode, which starts true. Ignored while stickToBottom is not effective.
typeGhostScrollAreaOverflowType"auto"Native overflow mode on enabled axes: auto or scroll.
SlotSlot propsDescription
default—Scrollable content inside the native overflow root.

@ghostvue/themes adds no props, events, or slots to the headless GhostScrollArea API, which it forwards.

Native attributes fall through to the scroll root (id, class, dir, aria-labelledby, sizing styles). The only model is v-model:stuck, used with stickToBottom.

Focus and naming ​

When content overflows and the slot has no tabbable descendants, the root receives tabindex="0". Provide label then so the tab stop is named (role="region" and aria-label). You can also name the region through fallthrough aria-labelledby together with an explicit role when you need a custom pattern. When buttons, links, or fields live inside, the root stays out of the tab order and keyboard users scroll via those controls or pointer. If such content arrives while the root itself has focus, the root keeps its tabindex, role, and name until it loses focus, so focus never drops to the page.

Accessibility ​

A focused native overflow root scrolls with platform keys (arrows, Page Up/Down, Home/End, Space). The component never handles or cancels keys. With stickToBottom, it only observes ArrowUp, PageUp, Home, and Shift+Space on the focused root to stop following before the browser scrolls; End (or any scroll that reaches the bottom) resumes it. RTL layouts inherit native horizontal scroll direction from dir on the root or document.

The root has no focus style of its own. Keyboard focus shows the browser's :focus-visible outline (or your app's) around the whole region, so keep ancestors from clipping the root's outer edge.

SSR renders data-overflow="none" and omits tabindex until the client measures layout.

Advanced: headless composition ​

The headless component from @ghostvue/vue renders the same root with no styles. Use it with your own scrollbar and spacing rules, or use useGhostScrollArea to apply the contract to an element you already render.

Headless region ​

Basic Headless

Bounded vertical overflow with native scrolling.

Event 1: backup checkpoint completed.

Event 2: backup checkpoint completed.

Event 3: backup checkpoint completed.

Event 4: backup checkpoint completed.

Event 5: backup checkpoint completed.

Event 6: backup checkpoint completed.

Event 7: backup checkpoint completed.

Event 8: backup checkpoint completed.

Event 9: backup checkpoint completed.

Event 10: backup checkpoint completed.

Event 11: backup checkpoint completed.

Event 12: backup checkpoint completed.

The example sets max-block-size inline. Everything else, including the native scrollbar, comes from the browser.

Composable path ​

Composable Headless

Same contract as GhostScrollArea on a native host.

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

useGhostScrollArea(options, element) returns rootProps to bind on your own host element. The returned props carry the same role, aria-label, tabindex, and data-* attributes as GhostScrollArea. Pass stickToBottom, stuck, and onStuckChange to opt in to following; the composable also returns a read-only stuck ref and scrollToBottom().

Styling hooks ​

The scroll root uses class ghost-scroll-area, data-part="root", data-orientation, data-type (auto or scroll), runtime data-overflow (none, vertical, horizontal, or both), and, with stickToBottom, data-stuck (true or false). Target overflow affordances without replacing native scrollbars:

css
.ghost-scroll-area[data-overflow='vertical'] {
  max-block-size: var(--panel-scroll-max, 16rem);
}