SkilVaultSign inStart free

Catalogue / css-scroll-containers

css-scroll-containers

Older skill: source not recordedSignedDecides whether a layout needs an inner scroll container or should be restructured for page-level scroll, writes one-axis overflow CSS, and defines auto-scroll, scroll-restore and error-scroll behavior for chat/log panels. Use when the user mentions scroll, overflow, scrollable, nested or inner scro…
---
name: css-scroll-containers
description: "Decides whether a layout needs an inner scroll container or should be restructured for page-level scroll, writes one-axis overflow CSS, and defines auto-scroll, scroll-restore and error-scroll behavior for chat/log panels. Use when the user mentions scroll, overflow, scrollable, nested or inner scroll in any CSS or component task, or when building tables, panels, drawers, sidebars, modals, chat logs or any fixed-height or long-list layout that might overflow — even if they only ask whether a region should scroll independently, or want existing overflow handling in CSS/TSX/JSX reviewed."
---

Scroll containers and overflow UX

1. Decide: inner scroll container or restructure

Prefer page-level alternatives first — pagination or load-more, accordions, a separate route, progressive disclosure — so the page itself does the scrolling.

Justify an inner scroll container for:

| Layout | Treatment | |---|---| | Fixed-height sidebar | Inner vertical scroll | | Sticky-header table | Inner vertical scroll; header stays fixed | | Chat/log panel | Inner vertical scroll with auto-scroll rules (step 3) | | Embedded editor/terminal | Inner scroll | | Wide table needing both axes | Restructure so the table's horizontal scroll is the only scroll in that region; the page does not scroll there |

Two live axes in one region are near-unusable on touch — pick one axis per region and restructure around it. Anything not in the table should scroll with the page or use the alternatives above.

2. Write the CSS

Bare overflow: auto leaves both axes scrollable; pin the unused axis with hidden:

.chat-log {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

For a horizontal-only container, reverse the pair: overflow-x: auto; overflow-y: hidden.

Keep the region discoverable:

  • Avoid scrollbar-width: none: a visible scrollbar track and a clipped partial item are the signals that more content exists.
  • On touch, the trailing partial item is the main affordance — keep that edge free of an outer overflow: hidden.
  • Do not hijack or artificially pace the native scroll event; touch users depend on native momentum scrolling.

3. Auto-scroll, restore, and error scrolling

For chat/log panels and similar streams:

  • Auto-scroll on new content only when the user is already at the bottom; otherwise show a new-messages indicator — yanking the view while they read history loses their place.
  • Scroll-to on load only to restore a prior scroll position; any other scroll on load fights the expectation of starting at the top.
  • Scroll to an error or anchor only in response to a user action, never automatically on render.

4. Review checklist

When auditing CSS/TSX/JSX for overflow handling, flag per region that scrolls or might overflow:

  • Bare overflow: auto (pin the unused axis), scrollbar-width: none, or a trailing edge clipped by an outer overflow: hidden.
  • Both axes live in one region — restructure per step 1.
  • Scroll listeners that intercept, rewrite, or pace scrolling.
  • Auto-scroll not gated on "already at bottom", scroll-on-load that is not a position restore, error/anchor scroll not tied to a user action.