ba-scroll
Scrolls the body of a React Native screen. Page spacing stays on the segments inside it, so the scroll indicator sits on the screen edge
Airframe
Web Components
React
React Native
Props
| Prop | Description | Type | Default |
|---|---|---|---|
children |
ReactNode |
||
contentInsetAdjustmentBehavior |
Defaults to "automatic" so liquid glass tab bars / nav bars insetcontent. Use "never" when a parent (e.g. screens SafeAreaView) alreadyowns the bottom inset and you need to avoid a large empty gap. |
"automatic" | "scrollableAxes" | "never" | "always" |
automatic |
fill |
Grow short content to the scroll viewport. Sets content flexGrow: 1 sotaller content can still grow and scroll. |
boolean |
false |
testID |
Used to locate this view in end-to-end tests. | string |
baScroll |
accessibilityLabel |
Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the Text nodes separated by space. |
string |
|
accessibilityHint |
An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label. | string |
|
accessibilityState |
Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on. | AccessibilityState |
Parent components
Put BaScroll inside <BaScreen>. Put <BaPageSegment> inside the scroll view.
Usage
BaScroll is the scrolling body of a screen. It fills the space left by BaScreen.
Keep page margin and vertical padding on the segment. A padded view around BaScroll insets the scroll indicator from the screen edge.
contentInsetAdjustmentBehavior defaults to automatic. On iOS, a translucent navigation bar or tab bar can inset the scroll content. A press on a button or link inside the scroll view registers while the keyboard is open. A press on empty space dismisses the keyboard.
On a screen under native bottom tabs, set safeAreaBottom={false} on BaScreen. The scroll view then owns the bottom inset, including the home indicator and an overlaying tab bar. Insets from react-native-safe-area-context leave out a liquid-glass tab bar.
Leave fill unset. Content keeps its own height, so a short page ends after the last item. Set fill when a short page should grow to the viewport, and set fill on the segment so the band fills that height. Taller content still scrolls.
Set contentInsetAdjustmentBehavior to never when the screen already applies the bottom inset and a large empty gap appears under the content.
Scrolling page
Put the segments inside BaScroll. Wrap neighbouring segments in BaPageSegmentGroup so matching themes share one block of padding.
<BaScreen>
<BaScroll>
<BaPageSegmentGroup>
<BaPageSegment>
<BaContent>
<BaText variant="header28">Your trip</BaText>
</BaContent>
</BaPageSegment>
<BaPageSegment>
<BaContent>
<BaText variant="body16">Flight details</BaText>
</BaContent>
</BaPageSegment>
</BaPageSegmentGroup>
</BaScroll>
</BaScreen>
Native bottom tabs
Set safeAreaBottom={false} on the screen. Leave contentInsetAdjustmentBehavior at automatic.
<BaScreen safeAreaBottom={false}>
<BaScroll>
<BaPageSegment>
<BaContent>
<BaText variant="body16">Tab content</BaText>
</BaContent>
</BaPageSegment>
</BaScroll>
</BaScreen>
Fixed header
Keep the header as a sibling of BaScroll. The header stays put. The segments inside the scroll view move.
<BaScreen>
<BaPageSegment>
<BaContent>
<BaText variant="header28">Your trip</BaText>
</BaContent>
</BaPageSegment>
<BaScroll>
<BaPageSegmentGroup>
<BaPageSegment>
<BaContent>
<BaText variant="body16">Flight details</BaText>
</BaContent>
</BaPageSegment>
</BaPageSegmentGroup>
</BaScroll>
</BaScreen>
Short page that fills the screen
Set fill on BaScroll and on the segment. The scroll view grows its content to the viewport, and the segment fills that height.
<BaScreen>
<BaScroll fill>
<BaPageSegment fill>
<BaContent>
<BaText variant="header28">Hello</BaText>
</BaContent>
</BaPageSegment>
</BaScroll>
</BaScreen>
Guidelines
BaScroll scrolls on the vertical axis. horizontal is not a available prop, so this component cannot scroll sideways.
VoiceOver and TalkBack move through the controls inside the scroll view in layout order. The component does not add its own announcements. Pass accessibilityLabel when the scroll view itself needs a name.
A press on a button or link inside the scroll view registers while the keyboard is open. A press on empty space dismisses the keyboard.
Keyboard navigation
State: BaScroll is a non-interactive container
Focus moves through the controls inside the scroll view