ScrollShadow

Fades scroll content at the edges that can still scroll.

  • Native host
  • New in 0.1
import { ScrollShadow, scrollShadowPrimitive } from "nitro-ui-sdk/scroll-shadow";
HeroUI Native
ScrollShadow
Expo UI
No counterpart
  • ScrollShadow example screen, light appearance
    Light
  • ScrollShadow example screen, dark appearance
    Dark
On this page

ScrollShadow is a scroll view whose edges fade while more content waits behind them: a long list in a card, a row of chips that scrolls sideways. The fade is a native gradient mask that follows the scroll position on the UI thread, so scrolling never reaches JavaScript.

Use a plain NitroUI ScrollView for full-screen scrolling, where the screen edges already show that content continues.

Anatomy

import { ScrollShadow } from "nitro-ui-sdk/scroll-shadow";
import { Text } from "nitro-ui-sdk/text";

<ScrollShadow layout={{ height: 240 }}>
  <Text>Stop 1</Text>
</ScrollShadow>;
Part Description
root The native fade host (KitScrollShadow) that wraps the scroll view and masks its edges.
content The scroll view’s content container: a column, or a row when horizontal.

ScrollShadow.Root is the same component as ScrollShadow.

Usage

import { ScrollShadow } from "nitro-ui-sdk/scroll-shadow";
import { Text } from "nitro-ui-sdk/text";

<ScrollShadow layout={{ height: 240 }}>
  <Text>Long content that scrolls.</Text>
</ScrollShadow>;

A vertical ScrollShadow needs a bounded height (height, or flexGrow inside a bounded parent). A horizontal one takes its content’s height.

Variants and sizes

orientation is vertical (default) or horizontal. size is the fade length in points (default 24). Zero disables the fade.

Visibility Behavior
auto An edge fades only while content hides behind it, ramping in over size points as you scroll. The default.
always Both edges always fade.
never No fade; a plain scroll view.
import { Chip } from "nitro-ui-sdk/chip";
import { ScrollShadow } from "nitro-ui-sdk/scroll-shadow";

<ScrollShadow orientation="horizontal" size={32} showsIndicator={false}>
  <Chip.Root label="All" />
  <Chip.Root label="Open" />
  <Chip.Root label="Closed" />
</ScrollShadow>;

States

ScrollShadow has no interactive states. With auto, content that fits draws no mask at all, so it renders without an offscreen pass.

Props

ScrollShadow

Prop Type Default Description
orientation "vertical" | "horizontal" "vertical" The scrolling axis.
size number 24 Fade length in points.
visibility "auto" | "always" | "never" "auto" When the edges fade.
showsIndicator boolean true Shows the scroll indicator for the axis.
styles ScrollShadowStyles Style resolvers for root and content.
layout LayoutStyleProps Layout of the host, e.g. its height.
children ReactNode Scrolling content.

Controller API

ScrollShadow has no value or commands, so it has no controller.

Styles

import { ScrollShadow, type ScrollShadowStyles } from "nitro-ui-sdk/scroll-shadow";

const styles: ScrollShadowStyles = {
  content: ({ tokens, variant }) => ({
    layout: { gap: variant === "horizontal" ? tokens.spacing.sm : tokens.spacing.md, padding: tokens.spacing.md },
  }),
};
<ScrollShadow layout={{ height: 200 }} styles={styles} />;

Parts: root, content. The variant is the orientation and the size is always md. Resolvers receive { tokens, variant, size, state } with state: { visibility; size: number }. scrollShadowEdges(visibility, size, metrics) is the same fade rule as the native view, exported for tests.

Accessibility

The host is not an accessibility element and the fade is visual only; VoiceOver reaches every child and scrolls the view with three-finger swipes. Content under a full fade is still readable by VoiceOver.

Agent API

Read-only. ScrollShadow adds no agent entry; controls inside it register themselves.

Platform notes

iOS Android
Fade Native ScrollShadowView (ios/layout/HybridNativeScrollShadow.swift): a CAGradientLayer mask on the host, updated by key-value observation of the scroll view’s contentOffset, contentSize and contentInset, with implicit animations off. No JavaScript per frame. A native alpha mask follows the platform scroll view’s offsets. Written, unbuilt on this machine.
Scrolling NitroUI ScrollView and ScrollViewContent, contentInsetAdjustmentBehavior="never". NitroUI ScrollView for vertical content. A native HorizontalScrollView hosts NitroUI content for the horizontal axis.