百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-magic-scroll

> 前端框架
开源

一种管理滚动视图和键盘的卡托式方法。

188 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一种管理滚动视图和键盘的卡托式方法。

About

App & Flow is a Montreal-based React Native engineering and consulting studio. We partner with the world’s top companies and are recommended by Expo. Need a hand? Let’s build together.

Why react-native-magic-scroll?

The goal of the library is to seamlessly and precisely handle your keyboard, scrollview and inputs when interacting with forms. While other solutions offer plug-and-play functionalities, we wanted to have something more precise and with more flexibility so that it can be used in any situation.

Examples

We recreated two flows from popular apps to showcase our library in action. The demo app code is available here.

Twitch's sign up Shop's check out

Installation

react-native-magic-scroll

bash
yarn add @appandflow/react-native-magic-scroll
bash
npm i @appandflow/react-native-magic-scroll

Dependencies

To use our library, you will need to install these two dependencies into your project.

1) React Native Reanimated

bash
npx expo install react-native-reanimated

Learn more about this dependency here.

2) SafeAreaContext

bash
npx expo install react-native-safe-area-context

Learn more about this dependency here.

Android

On Android, make sure to set android:windowSoftInputMode in your AndroidManifest.xml to pan

Expo

// app.json
"android": {
  ...rest,
  "softwareKeyboardLayoutMode": "pan"
}

Basic Usage

Wrap your screen within our ScrollView.

typescript
import { MagicScroll } from '@appandflow/react-native-magic-scroll';
// rest of your imports

const YourScreen = () => {
  return // Your form;
};

export default YourScreen;

You then use our TextInputs for the form itself, that you place inside the MagicScroll.ScrollView. Easily "chain" your inputs (so that the return keyboard button hops to the next desired input) by using the MagicScroll.TextInput name and chainTo props, like so:

…

You can also use the renderInput function and use any kind of input

…

Advanced

As mentioned in the introduction, the drawbacks of a plug-and-play library are its limitations when deviating from standard functionality. That's precisely why our library allows for customization, enabling you to tailor its usage to suit your specific needs and use cases.

Tips

It's a great idea to wrap our MagicScroll.TextInput within your own for re-usability!

Here's an example

typescript
import { MagicScroll } from '@appandflow/react-native-magic-scroll';

// rest of your imports

interface Props {
  label?: string;
  isPassword?: boolean;
  name?: string;
  description?: string;
  chainTo?: string;
}

const YourCustomInput = (props: Props) => {
  return (
     {props.label}}
      renderBottom={() => {props.description}}
      textInputProps={{
        secureTextEntry: props.isPassword,
        style: {
          height: 50,
          backgroundColor: '#ddd',
          borderRadius: 10,
          marginTop: 8,
        },
      }}
    />
  );
};

Props (Optional)

All of these props are optional. It is, however, recommended to use them to get the most out of the library.

MagicScroll.ScrollView

Name Description Values
additionalPadding adds extra padding between your text input and the keyboard number
scrollViewProps contains all props of the scrollview from React's Reanimated library props

MagicScroll.TextInput

Name Description Values
chainTo a string containing the name of the next text input that will be focused when pressing the "Enter Key" string
containerStyle contains all Style props of the View from React Native props
name a string to name the current text input, used in the "chainTo" props mentionned above string
renderBottom() a function that renders components to display custom text under the text input renderBottom={() => bottomText}
renderTop() a function that renders components to display custom text above the text input renderTop={() => topText}
textInputProps contains all props of the TextInput component from React Native props

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptexpokeyboardreact-nativescrollview

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架