Scroll

A native scroll container with vertical, horizontal or two-axis scrolling.

Import

import { Scroll } from "@tarve/core";

Usage

Scroll.tsx
import { Scroll, Text } from "@tarve/core";

let offset = 0;

<Scroll
  gap={8}
  padding={12}
  style={{ height: 240 }}
  onScroll={(next) => {
    offset = next;
  }}
>
  {Array.from({ length: 50 }, (_, index) => (
    <Text key={index}>Row {index + 1}</Text>
  ))}
</Scroll>

Props

PropTypeDefault
onScroll (offset: number, max: number) => void—
onScrollPosition (position: ScrollPosition) => void—
orientation ScrollOrientation"vertical"
speed number1
Inherited from ViewProps 11 props
PropTypeDefault
align Style["align"]—
dismissOnOutside boolean—
dragRegion boolean—
flex number—
focusable boolean—
gap number—
justify Style["justify"]—
onOutsideClick () => void—
padding Style["padding"]—
portal boolean—
windowAction "minimize" | "toggleMaximize" | "close"—

Common props

Shared by every component. See descriptions →

childrenhighlightidkeymotionFromonHighlightonPasteonTransitionEndrovingGroupstyle

Types

ScrollOrientation
type ScrollOrientation = "vertical" | "horizontal" | "both";
ScrollPosition
interface ScrollPosition { x: number; y: number; maxX: number; maxY: number }