是一套功能全面的 React Native UI 组件库,核心目标是为跨平台应用提供一致、美观且高度可定制的 UI 组件体系,覆盖从基础控件到复杂交互组件的全场景需求,简化 UI 开发流程并保证跨平台体验统一
文档模板:v0.4.2
react-native-ui-lib
本项目基于 react-native-ui-lib 开发。
该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:@react-native-ohos/react-native-ui-lib 版本所属关系如下:
| 三方库名称 | 三方库版本(npm地址) | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | 源码地址 |
|---|---|---|---|---|---|---|---|
| @react-native-ohos/react-native-ui-lib | ~ 7.44.0(开发中) | Gitcode Releases | 0.82.* | 是 | API12+ | 7.46.3 | master |
| @react-native-ohos/react-native-ui-lib | ~ 7.43.1 | Gitcode Releases | 0.77.* | 否 | API12+ | 7.43.0 | br_rnoh0.77 |
| @react-native-ohos/react-native-ui-lib | ~ 7.29.2 | Gitcode Releases | 0.72.* | 是 | API12+ | 7.29.1 | br_rnoh0.72 |
| @react-native-oh-tpl/react-native-ui-lib | <= 7.29.1-0.0.5@deprecated | Github Releases(deprecated) | 0.72.* | 否 | API12+ | 7.0.0 | br_rnoh0.72 |
简介
react-native-ui-lib 组件用于 React Native。
react-native-ui-lib 是一套功能全面的 React Native UI 组件库,核心目标是为跨平台应用提供一致、美观且高度可定制的 UI 组件体系,覆盖从基础控件到复杂交互组件的全场景需求,简化 UI 开发流程并保证跨平台体验一致。
下载安装
本库在 HarmonyOS 侧的实现依赖于 @react-native-ohos/react-native-reanimated 和 @react-native-ohos/react-native-gesture-handler 的原生代码。如已在 HarmonyOS 工程中集成过这些库,则无需重复引入,可跳过本章节,直接使用。
若尚未引入,请参考 @react-native-ohos/react-native-reanimated 文档 和 @react-native-ohos/react-native-gesture-handler 文档 进行集成。
以下为根据所使用的组件按需引入的依赖项:
-
@react-native-community/blur(Card 组件)
-
@react-native-community/datetimepicker(DateTimePicker 组件)
-
@react-native-community/netinfo(ConnectionStatusBar 组件)
进入工程目录并执行以下命令:
npm
npm install @react-native-ohos/react-native-ui-lib
yarn
yarn add @react-native-ohos/react-native-ui-lib
Link
| 是否支持autolink | RN框架版本 | |
|---|---|---|
| ~7.44.0 | 是 | 0.82 |
使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/CPF-RN/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
如您使用的版本支持 Autolink,并且工程已接入 Autolink,可跳过ManualLink配置。
ManualLink:此步骤为手动配置原生依赖项的指导
首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 harmony。
1. Overrides RN SDK
</需要翻译的内容>
{
...
"overrides": {
"@rnoh/react-native-openharmony" : "./react_native_openharmony"
}
}
2. 引入原生端代码
目前有两种方式可供选择:
- 通过 har 包引入;
- 直接链接源码。
方式一:通过 har 包引入(推荐)
har 包位于三方库安装路径下的 `harmony` 文件夹中。
打开 entry/oh-package.json5,添加以下依赖:
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
"@react-native-ohos/react-native-ui-lib": "file:../../node_modules/@react-native-ohos/react-native-ui-lib/harmony/ui_lib.har"
}
Click the sync button in the top-right corner
Or run the following in your command-line terminal:
cd entry
ohpm install
方法二:直接链接源码
如需使用直接链接源码,请参考[直接链接源码说明](https://gitcode.com/CPF-RN/usage-docs/blob/master/zh-cn/link-source-code.md)
3. 配置 CMakeLists 并引入 UiLibPackage
打开 entry/src/main/cpp/CMakeLists.txt,添加以下内容:
project(rnapp)
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
+ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
set(LOG_VERBOSITY_LEVEL 1)
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
add_compile_definitions(WITH_HITRACE_SYSTRACE)
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
# RNOH_BEGIN: manual_package_linking_1
add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
+ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-ui-lib/src/main/cpp" ./ui-lib)
# RNOH_END: manual_package_linking_1
file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
add_library(rnoh_app SHARED
${GENERATED_CPP_FILES}
"./PackageProvider.cpp"
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
)
target_link_libraries(rnoh_app PUBLIC rnoh)
# RNOH_BEGIN: manual_package_linking_2
target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
+ target_link_libraries(rnoh_app PUBLIC rnoh_ui_lib)
# RNOH_END: manual_package_linking_2
打开 entry/src/main/cpp/PackageProvider.cpp,添加:
#include "RNOH/PackageProvider.h"
#include "SamplePackage.h"
+ #include "UiLibPackage.h"
using namespace rnoh;
std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
return {
std::make_shared<SamplePackage>(ctx),
+ std::make_shared<UiLibPackage>(ctx),
};
}
4. 在 ArkTs 侧引入 HighlighterView 组件
找到 function buildCustomRNComponent(),通常位于 entry/src/main/ets/pages/index.ets 或 entry/src/main/ets/rn/LoadBundle.ets 文件中,添加以下代码:
...
+ import { HighlighterView } from "@react-native-ohos/react-native-ui-lib";
@Builder
export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
...
+ if (ctx.componentName === HighlighterView.NAME) {
+ HighlighterView({
+ ctx: ctx.rnComponentContext,
+ tag: ctx.tag
+ })
+ }
...
}
...
本库采用混合方案,需添加组件名称。
请在 entry/src/main/ets/pages/index.ets 或 entry/src/main/ets/rn/LoadBundle.ets 中找到常量 arkTsComponentNames,并在其数组中添加组件名称。
const arkTsComponentNames: Array<string> = [
SampleView.NAME,
GeneratedSampleView.NAME,
PropsDisplayer.NAME,
+ HighlighterView.NAME
];
5. 在 ArkTS 侧引入 UiLibPackage
打开 entry/src/main/ets/RNPackagesFactory.ts,添加以下代码:
...
+ import { UiLibPackage } from '@react-native-ohos/react-native-ui-lib/ts';
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
return [
new SamplePackage(ctx),
+ new UiLibPackage(ctx)
];
}
运行方式
点击右上角的 sync 按钮
或者在命令行终端中执行以下命令:
cd entry
ohpm install
然后编译、运行即可。
约束与限制
兼容性
本文档内容基于以下版本验证通过
- RNOH: 0.82.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
使用示例
下面的代码展示了这个库的基本使用场景:
使用时 import 的库名不变。
import React, {Component} from 'react';
import {Colors, Typography, Spacings, ThemeManager, View, Text, Card, Button} from 'react-native-ui-lib';
Colors.loadColors({
primaryColor: '#2364AA',
secondaryColor: '#81C3D7',
textColor: '#221D23',
errorColor: '#E63B2E',
successColor: '#ADC76F',
warnColor: '#FF963C'
});
Typography.loadTypographies({
heading: {fontSize: 36, fontWeight: '600'},
subheading: {fontSize: 28, fontWeight: '500'},
body: {fontSize: 18, fontWeight: '400'}
});
Spacings.loadSpacings({
page: 20,
card: 12,
gridGutter: 16
});
// with plain object
ThemeManager.setComponentTheme('Card', {
borderRadius: 8
});
// with a dynamic function
ThemeManager.setComponentTheme('Button', (props, context) => {
// 'square' is not an original Button prop, but a custom prop that can
// be used to create different variations of buttons in your app
if (props.square) {
return {
borderRadius: 0
};
}
});
class MyScreen extends Component {
render() {
return (
<View flex padding-page>
<Text heading marginB-s4>
My Screen
</Text>
<Card height={100} center padding-card marginB-s4>
<Text body>This is an example card </Text>
</Card>
<Button label="Button" body bg-primaryColor square></Button>
</View>
);
}
}
使用说明
BorderGradient
<Incubator.Gradient
type="border"
colors={[Colors.red30, Colors.purple30]}
width={250}
height={100}
borderWidth={6}
borderRadius={12}
>
<View center flex>
<Text text60 red30>Custom Content</Text>
<Text text90 grey40>Inside Border Gradient</Text>
</View>
</Incubator.Gradient>
CircleGradient
<Incubator.Gradient
type="circle"
colors={[Colors.red30, Colors.orange30]}
radius={40}
>
<View center flex>
<Text text60 white>OK</Text>
</View>
</Incubator.Gradient>
RectangleGradient
<Incubator.Gradient
type="rectangle"
colors={GRADIENT_COLORS}
width={200}
height={80}
>
<View center flex>
<Text text70 white>Rectangle</Text>
</View>
</Incubator.Gradient>
接口说明
“Platform”列表示该属性在原三方库上支持的平台。
“OpenHarmony Support”列为 yes 表示 OpenHarmony 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
组件
详细请查看 react-native-ui-lib 的文档介绍
Text:文本组件,该组件扩展了 Text 属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| animated | 将 Animated.Text 用作容器 | boolean | no | iOS/Android | yes |
| center | 是否将文本居中(使用 textAlign) | boolean | no | iOS/Android | yes |
| color | 文字颜色 | string | no | iOS/Android | yes |
| highlightString | 要高亮显示的子字符串。可以是简单的字符串或 HighlightStringProps 对象,或者上述类型的数组 | HighlightString |HighlightString[] | no | iOS/Android | yes |
| highlightStyle | 自定义强调字符串的高亮样式 | TextStyle | no | iOS/Android | yes |
| recorderTag | 记录器标签 | 'mask' |'unmask' | no | iOS/Android | yes |
| underline | 是否添加下划线 | boolean | no | iOS/Android | yes |
| uppercase | 是否将文本改为大写 | boolean | no | iOS/Android | yes |
TouchableOpacity:触摸反馈透明度组件,该组件扩展了 TouchableOpacity 属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| activeBackgroundColor | 当 TouchableOpacity 处于激活状态(按下时)时应用背景颜色 | string | no | iOS/Android | yes |
| backgroundColor | TouchableOpacity 的背景颜色 | string | no | iOS/Android | yes |
| customValue | 可传递给 TouchableOpacity 的任意类型自定义值,并在 onPress 回调中接收 | any | no | iOS/Android | yes |
| onPress | 按下回调 | (props?: TouchableOpacityProps & {event: GestureResponderEvent} |any) => void | no | iOS/Android | yes |
| recorderTag | 记录器标签 | 'mask'|'unmask' | no | iOS/Android | yes |
| style | 自定义样式 | ViewStyle | no | iOS/Android | yes |
| throttleOptions | 节流选项 | ThrottleOptions | no | iOS/Android | yes |
| throttleTime | 按下回调的节流时间(毫秒) | number | no | iOS/Android | yes |
| useNative | 应使用具有额外功能的增强本地实现 | boolean | no | iOS/Android | yes |
| activeScale | 将应用缩放按压反馈。这将强制使用 useNative 属性 | number | no | iOS/Android | yes |
View:容器组件,该组件扩展了 View 属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| animated | 将 Animate.View 用作容器 | boolean | no | iOS/Android | yes |
| backgroundColor | 设置背景颜色 | string | no | iOS/Android | yes |
| inaccessible | 关闭此视图及其子视图的辅助功能 | boolean | no | iOS/Android | yes |
| reanimated | 使用 Animate.View(来自 react-native-reanimated)作为容器 | boolean | no | iOS/Android | yes |
| recorderTag | 记录器标签 | 'mask'|'unmask' | no | iOS/Android | yes |
| renderDelay | 实验性:以毫秒为单位传递时间以延迟渲染 | number | no | iOS/Android | yes |
| style | 自定义样式 | ViewStyle | no | iOS/Android | yes |
| useSafeArea | 如果为 true,将呈现为 SafeAreaView | boolean | no | iOS/Android | yes |
ActionBar:快速操作栏,每个操作都支持按钮组件道具,该组件扩展了 View 属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| actions | 操作栏的操作 | ButtonProps[] | no | iOS/Android | yes |
| backgroundColor | 设置背景颜色 | string | no | iOS/Android | yes |
| centered | 行动是否应同样居中 | boolean | no | iOS/Android | yes |
| height | 高度 | number | no | iOS/Android | yes |
| keepRelative | 保持操作栏位置为相对,而不是绝对位置 | boolean | no | iOS/Android | yes |
| style | 组件的样式 | ViewStyle | no | iOS/Android | yes |
| useSafeArea | 在 iOS 中,使用安全区域,以防组件附着到底部 | boolean | no | iOS/Android | yes |
Button:按钮组件,该组件扩展了 TouchableOpacity 属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| animateLayout | 应该为布局变化添加动画。注意:对于 Android,必须通过 RN 的 'UIManager' 设置 'setLayoutAnimationEnabledExperimental(true)' | boolean | no | iOS/Android | yes |
| animateTo | 动画的方向(“左”和“右”会影响按钮自身的对齐方式) | ButtonAnimationDirection | no | iOS/Android | yes |
| avoidInnerPadding | 避免内部按钮间距 | boolean | no | iOS/Android | yes |
| avoidMinWidth | 避免最小宽度限制 | boolean | no | iOS/Android | yes |
| backgroundColor | 按钮背景颜色 | string | no | iOS/Android | yes |
| borderRadius | 自定义边角半径。 | number | no | iOS/Android | yes |
| color | 按钮文本颜色(继承自文本组件) | string | no | iOS/Android | yes |
| disabled | 禁用组件的交互 | boolean | no | iOS/Android | yes |
| disabledBackgroundColor | 禁用按钮背景颜色 | string | no | iOS/Android | yes |
| enableShadow | 控制阴影可见性(仅限 iOS) | boolean | no | iOS | yes |
| fullWidth | 按钮是否应作为跨屏按钮(无边角圆弧) | boolean | no | iOS/Android | yes |
| getActiveBackgroundColor | 用于获取 activeBackgroundColor 的回调(例如 (calculatedBackgroundColor, prop) => {...})。最好通过 ThemeManager 设置 | (backgroundColor: string, props: any) => string | no | iOS/Android | yes |
| hyperlink | 按钮看起来像一个超链接 | boolean | no | iOS/Android | yes |
| iconOnRight | 图标应该在标签的右边吗 | boolean | no | iOS/Android | yes |
| iconProps | 图标图片属性 | Partial | no | iOS/Android | yes |
| iconSource | 图标图像来源或返回来源的回调函数 | ImageProps['source']|Function | no | iOS/Android | yes |
| iconStyle | 图标图片样式 | ImageStyle | no | iOS/Android | yes |
| label | 按钮内显示的文本 | string | no | iOS/Android | yes |
| labelProps | 将传递给按钮文本标签的属性。 | TextProps | no | iOS/Android | yes |
| labelStyle | 标签文本的附加样式 | TextStyle | no | iOS/Android | yes |
| link | 按钮看起来像一个链接 | boolean | no | iOS/Android | yes |
| linkColor | 标签颜色(当显示为链接或超链接时) | string | no | iOS/Android | yes |
| onPress | 动作处理器 | (props: any) => void | no | iOS/Android | yes |
| outline | 按钮将采用轮廓样式 | boolean | no | iOS/Android | yes |
| outlineColor | 轮廓颜色 | string | no | iOS/Android | yes |
| outlineWidth | 轮廓宽度 | number | no | iOS/Android | yes |
| round | 按钮是否是圆形按钮 | boolean | no | iOS/Android | yes |
| size | 按钮的大小 [large, medium, small, xSmall] | ButtonSize | no | iOS/Android | yes |
| supportRTL | 图标在 RTL 语言环境下是否应水平翻转 | boolean | no | iOS/Android | yes |
| customBackground | 自定义背景颜色 | React.ReactElement | no | iOS/Android | yes |
Checkbox:复选框组件,该组件扩展了 TouchableOpacity 属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| borderRadius | 复选框边框圆角 | number | no | iOS/Android | yes |
| color | 复选框颜色 | string | no | iOS/Android | yes |
| containerStyle | 复选框和标签容器的自定义样式 | ViewStyle | no | iOS/Android | yes |
| disabled | 复选框是否应被禁用 | boolean | no | iOS/Android | yes |
| iconColor | 所选图标颜色 | string | no | iOS/Android | yes |
| label | 为复选框添加标签 | string | no | iOS/Android | yes |
| labelProps | 传递给标签组件的属性 | TextProps | no | iOS/Android | yes |
| labelStyle | 传递以设置标签样式 | TextStyle | no | iOS/Android | yes |
| onChangeValidity | 字段有效性更改时的回调 | (isValid: boolean) => void | no | iOS/Android | yes |
| onValueChange | 值变化事件的回调函数 | (value) => void | no | iOS/Android | yes |
| outline | 替代复选框轮廓样式 | boolean | no | iOS/Android | yes |
| required | 是否需要复选框 | boolean | no | iOS/Android | yes |
| selectedIcon | 用于所选指示的图标资源 | ImageRequireSource | no | iOS/Android | yes |
| size | 复选框的大小会影响宽度和高度 | number | no | iOS/Android | yes |
| style | 复选框的自定义样式 | ViewStyle | no | iOS/Android | yes |
| value | 复选框的值。如果为真,开关将被打开。默认值为假 | boolean | no | iOS/Android | yes |
Chip:芯片组件,该组件扩展了 TouchableOpacity,View 属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| avatarProps | Avatar 属性 | AvatarProps | no | iOS/Android | yes |
| backgroundColor | 背景色 | string | no | iOS/Android | yes |
| badgeProps | Badge 属性 | BadgeProps | no | iOS/Android | yes |
| borderRadius | Border 半径 | number | no | iOS/Android | yes |
| containerStyle | Component's container 风格 | ViewStyle | no | iOS/Android | yes |
| dismissColor | Dismiss 颜色 | string | no | iOS/Android | yes |
| dismissContainerStyle | Dismiss container 风格 | ImageStyle | no | iOS/Android | yes |
| dismissIcon | Dismiss 资源 | ImageSourcePropType | no | iOS/Android | yes |
| dismissIconStyle | Dismiss 风格 | ImageStyle | no | iOS/Android | yes |
| iconProps | Additional icon 属性 | Omit<ImageProps, 'source'> | no | iOS/Android | yes |
| iconSource | Left icon's 资源 | ImageSourcePropType | no | iOS/Android | yes |
| iconStyle | Icon 风格 | ImageStyle | no | iOS/Android | yes |
| label | 显式的文本 | string | no | iOS/Android | yes |
| labelStyle | Label 的风格 | TextStyle | no | iOS/Android | yes |
| leftElement | 左边自定义元素 | JSX.Element | no | iOS/Android | yes |
| onDismiss | 添加一个关闭按钮并作为其回调 | (props: any) => void | no | iOS/Android | yes |
| onPress | 芯片按下回调 | (props: any) => void | no | iOS/Android | yes |
| resetSpacings | 禁用所有内部元素的默认间距,有助于实现自定义设计 | boolean | no | iOS/Android | yes |
| rightElement | 右边自定义元素 | JSX.Element | no | iOS/Android | yes |
| rightIconSource | 右边图标地址 | ImageSourcePropType | no | iOS/Android | yes |
| size | 芯片的尺寸。数字或宽度和高度对象 | number|{{width: number, height: number}} | no | iOS/Android | yes |
| testID | 端到端测试的测试 ID | string | no | iOS/Android | yes |
| useCounter | 以计数器显示徽章(无背景) | boolean | no | iOS/Android | yes |
| useSizeAsMinimum | 使用大小作为最小宽度和最小高度 | boolean | no | iOS/Android | yes |
RadioButton:单选按钮组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| borderRadius | 单选按钮边框半径 | number | 否 | iOS/Android | 是 |
| color | 单选按钮的颜色 | string | 否 | iOS/Android | 是 |
| containerStyle | 容器的附加样式 | ViewStyle | 否 | iOS/Android | 是 |
| contentOnLeft | 内容是否应左对齐到按钮 | boolean | 否 | iOS/Android | 是 |
| disabled | 是否应禁用单选按钮 | boolean | 否 | iOS/Android | 是 |
| iconOnRight | 图标是否应放在标签的右侧 | boolean | 否 | iOS/Android | 是 |
| iconSource | 图标图片来源 | ImageSource | 否 | iOS/Android | 是 |
| iconStyle | 图标图片样式 | ImageStyle | 否 | iOS/Android | 是 |
| label | 单选按钮描述的标签 | string | 否 | iOS/Android | 是 |
| labelStyle | 标签样式 | TextStyle | 否 | iOS/Android | 是 |
| onPress | 按下按钮时调用 | (selected: boolean) => void | 否 | iOS/Android | 是 |
| selected | 在不使用 RadioGroup 的情况下使用 RadioButton 时,使用此属性来切换选中状态 | boolean | 否 | iOS/Android | 是 |
| size | 单选按钮的大小,影响宽度和高度 | number | 否 | iOS/Android | 是 |
| value | 单选按钮的标识值,必须与同一组中的其他单选按钮不同 | string | number | boolean | 否 | iOS/Android | 是 |
RadioGroup:包裹单选按钮组件,与 RadioButton 配合使用。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| initialValue | 所选单选按钮的初始值 | string | number | boolean | 否 | iOS/Android | 是 |
| onValueChange | 当通过选择组中的一个单选按钮而更改值时调用一次 | ((value?: string) => void)|((value?: number) => void)|((value?: boolean) => void)|((value?: any) => void) | 否 | iOS/Android | 是 |
Slider:滑块组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| accessible | 如果为真,该组件将启用辅助功能 | boolean | 否 | iOS/Android | 是 |
| activeThumbStyle | 按压时的样式 | ViewStyle | 否 | iOS/Android | 是 |
| containerStyle | 容器样式 | ViewStyle | 否 | iOS/Android | 是 |
| disableActiveStyling | 如果为真,滑块在按下时不会改变其样式 | boolean | 否 | iOS/Android | 是 |
| disableRTL | 如果为 true,即使应用程序处于从右到左模式,滑块仍将保持从左到右模式 | boolean | 否 | iOS/Android | 是 |
| disabled | 如果为 true,滑块将被禁用,并显示为禁用颜色 | boolean | 否 | iOS/Android | 是 |
| initialMaximumValue | 只有当 useRange 为 true 时,初始最大值 |
number | 否 | iOS/Android | 是 |
| initialMinimumValue | 只有当 useRange 为 true 时,初始最小值 |
number | 否 | iOS/Android | 是 |
| maximumTrackTintColor | 轨道颜色 | string | 否 | iOS/Android | 是 |
| maximumValue | 追踪最大值 | number | 否 | iOS/Android | 是 |
| migrate | 迁移到滑块新实现所需的临时属性 | boolean | 否 | iOS/Android | 是 |
| minimumTrackTintColor | 用于从最小值到当前值的轨道颜色 | string | 否 | iOS/Android | 是 |
| minimumValue | 追踪最小值 | number | 否 | iOS/Android | 是 |
| onRangeChange | onRangeChange 的回调,返回包含最小值和最大值的值对象 | SliderOnRangeChange | 否 | iOS/Android | 是 |
| onReset | 当重置功能被调用时的回调通知 | () => void | 否 | iOS/Android | 是 |
| onSeekEnd | 回调,用于通知滑块拖动已完成 | () => void | 否 | iOS/Android | 是 |
| onSeekStart | 回调,用于通知滑块开始拖动 | () => void | 否 | iOS/Android | 是 |
| onValueChange | onValueChange 的回调 | SliderOnValueChange | 否 | iOS/Android | 是 |
| renderTrack | 自定义渲染而不是渲染轨道 | () => ReactElement | ReactElement[] | 否 | iOS/Android | 是 |
| step | 滑块的步长值,该值应介于 0 与(最大值 - 最小值)之间 | number | 否 | iOS/Android | 是 |
| testID | 组件测试 ID | string | 否 | iOS/Android | 是 |
| thumbStyle | thumb 样式 | ViewStyle | 否 | iOS/Android | 是 |
| thumbTintColor | Thumb 颜色 | string | 否 | iOS/Android | 是 |
| trackStyle | track 样式 | ViewStyle | 否 | iOS/Android | 是 |
| useGap | 如果为 true,最小值和最大值的滑块将不会重叠 | boolean | 否 | iOS/Android | 是 |
| useRange | 如果为 true,滑块将显示用于最小值的第二个滑块按钮 | boolean | 否 | iOS/Android | 是 |
| value | 初始值 | number | 否 | iOS/Android | 是 |
Switch:开关切换组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| disabled | 是否应禁用开关 | boolean | 否 | iOS/Android | 是 |
| disabledColor | 开关禁用时的背景颜色 | string | 否 | iOS/Android | 是 |
| height | 开关高度 | number | 否 | iOS/Android | 是 |
| id | 组件 id | string | 否 | iOS/Android | 是 |
| offColor | 开关关闭时的背景颜色 | string | 否 | iOS/Android | 是 |
| onColor | 开关开启时的背景颜色 | string | 否 | iOS/Android | 是 |
| onValueChange | 当值发生变化时,使用新值调用 | (value: boolean) => void | 否 | iOS/Android | 是 |
| style | 自定义样式 | ViewStyle | 否 | iOS/Android | 是 |
| testID | 组件测试 id | string | 否 | iOS/Android | 是 |
| thumbColor | Switch 的摇杆颜色 | string | 否 | iOS/Android | 是 |
| thumbSize | Switch 拇指大小(宽度和高度) | number | 否 | iOS/Android | 是 |
| thumbStyle | Switch 的拇指风格 | ViewStyle | 否 | iOS/Android | 是 |
| value | 开关的值,如果为 true,开关将被打开,默认值为 false | boolean | 否 | iOS/Android | 是 |
| width | 开关宽度 | number | 否 | iOS/Android | 是 |
ChipsInput:芯片输入组件,该组件扩展了 TextField 属性。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| chips | 要渲染的芯片列表 | ChipProps[] | 否 | iOS/Android | 是 |
| defaultChipProps | 默认要传递给所有芯片的属性集合 | ChipProps | 否 | iOS/Android | 是 |
| maxChips | 允许添加的最大芯片数 | number | 否 | iOS/Android | 是 |
| onChange | item 变更回调(添加或移除 item) | (newChips, changeReason, updatedChip) => void | 否 | iOS/Android | 是 |
ColorPalette:调色板组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| animatedIndex | 默认值为最后一项,首次渲染时要动画的项目索引 | number | 否 | iOS/Android | 是 |
| backgroundColor | ColorPalette 的背景颜色 | string | 否 | iOS/Android | 是 |
| colors | 调色板中要显示的颜色数组 | string[] | 否 | iOS/Android | 是 |
| containerStyle | 组件的容器样式 | ViewStyle | 否 | iOS/Android | 是 |
| containerWidth | 容器边距 | number | 否 | iOS/Android | 是 |
| loop | 颜色分页是否循环滚动 | boolean | 否 | iOS/Android | 是 |
| numberOfRows | 颜色行数,从 2 到 5 | number | 否 | iOS/Android | 是 |
| onValueChange | 当通过选择调色板中的一个色块而更改值时调用一次 | (value: string, colorInfo: ColorInfo) => void | 否 | iOS/Android | 是 |
| style | 组件样式 | ViewStyle | 否 | iOS/Android | 是 |
| swatchStyle | 样式,用于调色板中的所有颜色样本 | ViewStyle | 否 | iOS/Android | 是 |
| testID | 端到端测试的测试 ID | string | 否 | iOS/Android | 是 |
| usePagination | 当颜色数量超过行数时是否使用分页 | boolean | 否 | iOS/Android | 是 |
| value | 所选色样的数值 | string | 否 | iOS/Android | 是 |
ColorPicker:选色器组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| accessibilityLabels | 作为字符串对象的无障碍标签 | { addButton: string, dismissButton: string, doneButton: string, input: string} | 否 | iOS/Android | 是 |
| animatedIndex | 默认为最后一项,首次渲染时要动画的项目索引 | number | 否 | iOS/Android | 是 |
| backgroundColor | ColorPicker 的背景颜色 | string | 否 | iOS/Android | 是 |
| colors | 用于选择器调色板的颜色数组(十六进制值) | string[] | 否 | iOS/Android | 是 |
| onValueChange | 选择器调色板更改的回调 | (value: string, colorInfo: ColorInfo) => void | 否 | iOS/Android | 是 |
| testID | 用于端到端测试的测试 ID | string | 否 | iOS/Android | 是 |
| value | 所选色样的数值 | string | 否 | iOS/Android | 是 |
ColorSwatch:颜色样板组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| animated | 首次渲染是否应动画化 | boolean | 否 | iOS/Android | 是 |
| color | ColorSwatch 的颜色 | string | 否 | iOS/Android | 是 |
| index | 如果在数组中,色样的索引 | number | 否 | iOS/Android | 是 |
| onPress | 按下事件的回调 | (value: string, colorInfo: ColorInfo) => void | 否 | iOS/Android | 是 |
| selected | 初始状态是否被选中 | boolean | 否 | iOS/Android | 是 |
| size | 颜色色样尺寸 | number | 否 | iOS/Android | 是 |
| style | 组件的样式 | ViewStyle | 否 | iOS/Android | 是 |
| testID | 用于端到端测试的测试 ID | string | 否 | iOS/Android | 是 |
| unavailable | 初始状态是否不可用 | boolean | 否 | iOS/Android | 是 |
| value | 必须与同一组中的其他 ColorSwatch 不同,ColorSwatch 调色板中 ColorSwatch 的标识符值 | string | 否 | iOS/Android | 是 |
DateTimePicker:时间选择组件,该组件扩展了 TextField 属性,依赖 @react-native-community/datetimepicker 库。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| dateTimeFormatter | 用于格式化时间或日期的回调函数 | (value: Date, mode: DateTimePickerMode) => string | 否 | iOS/Android | 是 |
| dialogProps | 传递给 Dialog 组件的属性 | DialogProps | 否 | iOS/Android | 是 |
| display | 定义选择器的视觉显示。iOS 上的默认值为“spinner”,Android 上的默认值为“default”。所有可能值的列表包括 Android 上的 default、spinner、calendar 或 clock,以及 iOS 上的 default、spinner、compact 或 inline。完整列表可以在这里找到:react-native-datetimepicker | string | 否 | iOS/Android | 部分支持(default,inline,compact) |
| editable | 此输入是否应可编辑或禁用 | boolean | 否 | iOS/Android | 是 |
| headerStyle | 应用于 iOS 对话框标题的样式 | ViewStyle | 否 | iOS/Android | 是 |
| is24Hour | 仅限 Android,允许将时间选择器更改为 24 小时格式 | boolean | 否 | Android | 否 |
| locale | 仅限 iOS,允许更改组件的区域设置 | string | 否 | iOS | 否 |
| maximumDate | 要使用的最大日期或时间值 | Date | 否 | iOS/Android | 是 |
| minimumDate | 要使用的最小日期或时间值 | Date | 否 | iOS/Android | 是 |
| minuteInterval | 仅限 iOS,可以选择分钟的间隔。可能的值是:1、2、3、4、5、6、10、12、15、20、30 | number | 否 | iOS | 否 |
| mode | 要显示的选择器类型(“date”或“time”) | DATE |TIME | 否 | iOS/Android | 是 |
| onChange | 当日期/时间更改时调用 | () => Date | 否 | iOS/Android | 是 |
| renderInput | 渲染自定义输入 | JSX.Element | 否 | iOS/Android | 是 |
| themeVariant | 覆盖日期选择器使用的系统主题变体(深色或浅色模式) | LIGHT |DARK | 否 | iOS/Android | 否 |
| timeZoneOffsetInMinutes | 仅限 iOS,允许更改日期选择器的时区。默认使用设备的时区 | number | 否 | iOS | 否 |
| value | 默认为设备的日期和时间,设置选择器的初始值 | Date | 否 | iOS/Android | 是 |
| backgroundColor | 滚轮选择器的背景颜色 | string | 否 | iOS/Android | 是 |
| textColor | 滚轮选择器项目的文本颜色 | string | 否 | iOS/Android | 否 |
MaskedInput:掩码输入组件,该组件扩展了TextInput属性。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| containerStyle | 掩码输入容器的容器样式 | ViewStyle | 否 | iOS/Android | 否 |
| renderMaskedText | 用于从实际输入返回的值渲染自定义输入的回调 | React.ReactElement | 否 | iOS/Android | 否 |
NumberInput:数字输入框组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| containerStyle | 整个组件的容器样式 | ViewStyle | 否 | iOS/Android | 否 |
| contextMenuHidden | 需要安装 @react-native-community/clipboard。如果为 true,则上下文菜单隐藏。 | boolean | 否 | iOS/Android | 否 |
| fractionDigits | 小数点后的位数。必须在 0 - 20 的范围内(含)。 | number | 否 | iOS/Android | 否 |
| initialNumber | 有效的数字(在 en 区域设置中,即仅数字和小数点)。 | number | 否 | iOS/Android | 否 |
| leadingText | 前导文本 | string | 否 | iOS/Android | 否 |
| leadingTextStyle | 前导文本的样式 | TextStyle | 否 | iOS/Android | 否 |
| onChangeNumber | 当数字值更改时调用的回调。 | (data: NumberInputData) => void | 否 | iOS/Android | 否 |
| textFieldProps | 除了通过命名属性直接传递的属性外,可以应用大多数 TextField 的属性。 | TextFieldProps | 否 | iOS/Android | 否 |
| trailingText | 尾随文本 | string | 否 | iOS/Android | 否 |
| trailingTextStyle | 尾随文本的样式 | ViewStyle | 否 | iOS/Android | 否 |
Picker:弹窗选择组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| customPickerProps | 自定义选择器属性(使用 renderPicker 时,将应用于按钮包装器) | object | 否 | iOS/Android | 是 |
| enableModalBlur | 仅限 iOS,为选择器模态添加模糊效果 | boolean | 否 | iOS | 是 |
| fieldType | 为不同的字段类型 UI 传递(表单、过滤器或设置) | PickerFieldTypes | 否 | iOS/Android | 是 |
| getLabel | 返回所选 Picker 值要显示的标签的函数 | (value: string | number) => void | 否 | iOS/Android | 是 |
| items | Picker 的数据源 | {label: string, value: string | number}[] | 否 | iOS/Android | 是 |
| listProps | 传递给包装选择器选项的列表组件的属性(允许控制 FlatList 行为) | FlatListProps | 否 | iOS/Android | 是 |
| mode | 单选模式或多选模式 | SINGLE | MULTI | 否 | iOS/Android | 是 |
| onChange | 当选择器值更改时的回调 | (value: string | number) => void | 否 | iOS/Android | 是 |
| onPress | 为按下选择器时添加 onPress 回调 | () => void | 否 | iOS/Android | 是 |
| onSearchChange | 选择器模态搜索输入文本更改的回调(仅在传递 showSearch 时) | (searchValue: string, filteredItems?: PickerFilteredItems) => void | 否 | iOS/Android | 是 |
| pickerModalProps | 传递给选择器模态的属性 | ModalProps | 否 | iOS/Android | 是 |
| renderCustomModal | 渲染自定义选择器模态 | ({visible, children, toggleModal}) => void) | 否 | iOS/Android | 是 |
| renderCustomSearch | 渲染自定义搜索输入(仅在传递 showSearch 时) | (props) => void | 否 | iOS/Android | 是 |
| renderItem | 渲染自定义选择器项 | (value, {{...props, isSelected}}, itemLabel) => void | 否 | iOS/Android | 是 |
| renderPicker | 渲染自定义选择器 - 输入将是值(见上文)\示例:\renderPicker = (selectedItem) => {...} | (selectedItem, itemLabel) => void | 否 | iOS/Android | 是 |
| searchPlaceholder | 搜索输入的占位符文本(仅在传递 showSearch 时) | string | 否 | iOS/Android | 是 |
| searchStyle | 搜索输入的样式对象(仅在传递 showSearch 时) | {color: string, placeholderTextColor: string, selectionColor: string} | 否 | iOS/Android | 是 |
| selectionLimit | 限制所选项目的数量 | number | 否 | iOS/Android | 是 |
| showSearch | 显示搜索输入以按标签过滤选择器项 | boolean | 否 | iOS/Android | 是 |
| topBarProps | 选择器模态顶部栏属性 | Modal's TopBarProps | 否 | iOS/Android | 是 |
| useSafeArea | 在选择器模态视图中添加安全区域 | boolean | 否 | iOS/Android | 是 |
| useWheelPicker | 使用滚轮选择器而不是列表选择器 | boolean | 否 | iOS/Android | 是 |
| value | 选择器当前值 | string | number | 否 | iOS/Android | 是 |
| renderCustomTopElement | 渲染自定义顶部元素 | (value?: PickerValue) => React.ReactElement | 否 | iOS/Android | 是 |
| showLoader | 显示加载器(当项目正在加载/获取时) | boolean | 否 | iOS/Android | 是 |
| customLoaderElement | 自定义加载器元素 | ReactNode | 否 | iOS/Android | 是 |
Picker.Item:弹窗选择项组件,配合 Picker 组件使用。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| disabled | 项目是否禁用 | boolean | 否 | iOS/Android | 是 |
| label | 项目的标签 | string | 否 | iOS/Android | 是 |
| labelStyle | 项目的标签样式 | ViewStyle | 否 | iOS/Android | 是 |
| onPress | onPress 操作的回调,如果返回 false 将停止选择 | (selected: boolean | undefined, props: any) => void | Promise; | 否 | iOS/Android | 是 |
| selectedIcon | 传递以更改选中图标 | ImageSource | 否 | iOS/Android | 是 |
| selectedIconColor | 传递以更改选中图标的颜色 | string | 否 | iOS/Android | 是 |
| value | 项目的值 | string | number | 否 | iOS/Android | 是 |
SectionsWheelPicker:滚动选择组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| activeTextColor | 聚焦行的文本颜色 | string | 否 | iOS/Android | 是 |
| faderProps | 淡入淡出器的自定义属性。 | FaderProps | 否 | iOS/Android | 是 |
| inactiveTextColor | 其他非聚焦行的文本颜色 | string | 否 | iOS/Android | 是 |
| itemHeight | 描述 WheelPicker 中每个项目的高度 | number | 否 | iOS/Android | 是 |
| numberOfVisibleRows | 描述可见行数 | number | 否 | iOS/Android | 是 |
| sections | 部分数组 | WheelPickerProps | 否 | iOS/Android | 是 |
| testID | 组件测试 ID | string | 否 | iOS/Android | 是 |
| textStyle | 行文本样式 | TextStyle | 否 | iOS/Android | 是 |
SegmentedControl:切换值组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| activeBackgroundColor | 活动段落的背景颜色 | string | 否 | iOS/Android | 是 |
| activeColor | 活动段落标签的颜色 | string | 否 | iOS/Android | 是 |
| backgroundColor | 非活动段落的背景颜色 | string | 否 | iOS/Android | 是 |
| borderRadius | SegmentedControl 的边框半径 | number | 否 | iOS/Android | 是 |
| containerStyle | 容器的额外间距样式 | ViewStyle | 否 | iOS/Android | 是 |
| iconOnRight | 图标是否应在标签的右侧 | boolean | 否 | iOS/Android | 是 |
| initialIndex | 初始激活的索引 | number | 否 | iOS/Android | 是 |
| onChangeIndex | 当索引更改时的回调。 | (index: number) => void | 否 | iOS/Android | 是 |
| outlineColor | 活动段落的轮廓颜色 | string | 否 | iOS/Android | 是 |
| outlineWidth | 活动段落的轮廓宽度 | number | 否 | iOS/Android | 是 |
| segmentLabelStyle | 段落标签样式 | TextStyle | 否 | iOS/Android | 是 |
| segments | 段落数组 | SegmentedControlItemProps | 否 | iOS/Android | 是 |
| segmentsStyle | 段落的额外样式 | ViewStyle | 否 | iOS/Android | 是 |
| style | 内部容器的自定义样式 | ViewStyle | 否 | iOS/Android | 是 |
| testID | 组件测试 ID | string | 否 | iOS/Android | 是 |
| throttleTime | 更改索引的尾随节流时间(毫秒)。 | number | 否 | iOS/Android | 是 |
| label | SegmentedControl 标签 | string | 否 | iOS/Android | 是 |
| labelProps | 为 SegmentedControl 标签传递属性 | TextProps | 否 | iOS/Android | 是 |
Stepper:步进器组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| accessibilityLabel | 组件无障碍标签 | string | 否 | iOS/Android | 是 |
| disabled | 禁用与步进器的交互 | boolean | 否 | iOS/Android | 是 |
| maxValue | 最大值 | number | 否 | iOS/Android | 是 |
| minValue | 最小值 | number | 否 | iOS/Android | 是 |
| onValueChange | 值更改回调函数 | (value: number, testID?: string) => void | 否 | iOS/Android | 是 |
| small | 渲染小尺寸的步进器 | boolean | 否 | iOS/Android | 是 |
| step | 增加和减少的步长(默认为 1) | number | 否 | iOS/Android | 是 |
| testID | 组件测试 ID | string | 否 | iOS/Android | 是 |
| value | 步进器值 | number | 否 | iOS/Android | 是 |
| type | 步进器样式类型 | StepperType | 否 | iOS/Android | 是 |
TextField:文本域组件,扩展了TextInput属性。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| centered | 是否将 TextField 容器和标签居中 | boolean | 否 | iOS/Android | 否 |
| charCounterStyle | 为字符计数器文本传递自定义样式 | TextStyle | 否 | iOS/Android | 否 |
| color | 输入文本的颜色 | ColorType | 否 | iOS/Android | 否 |
| containerProps | 整个组件的容器属性 | Omit<ViewProps, 'style'> | 否 | iOS/Android | 否 |
| containerStyle | 整个组件的容器样式 | ViewStyle | 否 | iOS/Android | 否 |
| enableErrors | 是否支持显示验证错误消息 | boolean | 否 | iOS/Android | 否 |
| fieldStyle | 字段容器的内部样式,用于设置下划线、轮廓和填充颜色 | ViewStyle | (context: FieldContextType, props) => ViewStyle | 否 | iOS/Android | 否 |
| floatOnFocus | 占位符是否应在聚焦或开始输入时浮动 | boolean | 否 | iOS/Android | 否 |
| floatingPlaceholder | 传入以启用浮动占位符功能 | boolean | 否 | iOS/Android | 否 |
| floatingPlaceholderColor | 浮动占位符的颜色 | ColorType | 否 | iOS/Android | 否 |
| floatingPlaceholderStyle | 浮动占位符的自定义样式 | TextStyle | 否 | iOS/Android | 否 |
| formatter | 输入值的自定义格式化器(仅在输入框未聚焦时生效) | (value) => string | undefined | 否 | iOS/Android | 否 |
| hint | 字段聚焦时显示的提示文本 | string | 否 | iOS/Android | 否 |
| label | 字段标签 | string | 否 | iOS/Android | 否 |
| labelColor | 字段标签颜色,可为字符串或按状态映射的颜色({default, focus, error, disabled, readonly}) | ColorType | 否 | iOS/Android | 否 |
| labelProps | 为标签文本元素传递额外属性 | TextProps | 否 | iOS/Android | 否 |
| labelStyle | 字段标签的自定义样式 | TextStyle | 否 | iOS/Android | 否 |
| leadingAccessory | 传入以渲染前导元素 | ReactElement | 否 | iOS/Android | 否 |
| onChangeValidity | 字段有效性变化时的回调 | (isValid: boolean) => void | 否 | iOS/Android | 否 |
| onValidationFailed | 字段验证失败时的回调 | (failedValidatorIndex: number) => void | 否 | iOS/Android | 否 |
| placeholder | 字段的占位符文本 | string | 否 | iOS/Android | 否 |
| placeholderTextColor | 占位符文本的颜色 | ColorType | 否 | iOS/Android | 否 |
| preset | 用于设置字段样式的预定义预设 | 'default' | null |string | 否 | iOS/Android | 否 |
| readonly | 只读状态的 UI 预设 | boolean | 否 | iOS/Android | 否 |
| recorderTag | 记录器标签 | 'mask' | 'unmask' | 否 | iOS/Android | 否 |
| retainValidationSpace | 即使没有验证消息也保留验证区域 | boolean | 否 | iOS/Android | 否 |
| showCharCounter | 是否显示字符计数器(仅在设置 maxLength 时生效) | boolean | 否 | iOS/Android | 否 |
| showMandatoryIndication | 是否显示必填字段指示 | boolean | 否 | iOS/Android | 否 |
| trailingAccessory | 传入以渲染尾随元素 | ReactElement | 否 | iOS/Android | 否 |
| useGestureHandlerInput | 为基础 TextInput 使用 react-native-gesture-handler 而非 react-native | boolean | 否 | iOS/Android | 否 |
| validate | 单个或多个验证器,可以是字符串(如 required、email)或自定义函数 | Validator | Validator [] | 否 | iOS/Android | 否 |
| validateOnBlur | 是否在 TextField 失去焦点时进行验证 | boolean | 否 | iOS/Android | 否 |
| validateOnChange | 是否在 TextField 值变化时进行验证 | boolean | 否 | iOS/Android | 否 |
| validateOnStart | 是否在 TextField 挂载时进行验证 | boolean | 否 | iOS/Android | 否 |
| validationMessage | 字段无效时显示的验证消息(取决于 validate 设置) | string | string[] | 否 | iOS/Android | 否 |
| validationMessagePosition | 验证消息的位置(顶部/底部) | ValidationMessagePosition | 否 | iOS/Android | 否 |
| validationMessageStyle | 验证消息的自定义样式 | TextStyle | 否 | iOS/Android | 否 |
| validationDebounceTime | 设置 validateOnChange 触发时的防抖延时时间 | number | 否 | iOS/Android | 否 |
| innerFlexBehavior | 设置内部容器使用 flex 行为,以解决使用前导或尾随附件时的文本溢出问题(当字段位于行容器内时可能会导致 flex 问题) | boolean | 否 | iOS/Android | 否 |
WheelPicker:轮式选择器组件。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| activeTextColor | 当前聚焦行的文本颜色 | string | 否 | iOS/Android | 是 |
| align | 将内容对齐到中心、右侧或左侧 | WheelPickerAlign | 否 | iOS/Android | 是 |
| flatListProps | 传递给 FlatList 的属性 | FlatListProps | 否 | iOS/Android | 是 |
| inactiveTextColor | 其他非聚焦行的文本颜色 | string | 否 | iOS/Android | 是 |
| initialValue | 初始值(非受控模式) | number | string | 否 | iOS/Android | 是 |
| itemHeight | WheelPicker 中每个项目的高度 | number | 否 | iOS/Android | 是 |
| items | WheelPicker 的数据源 | WheelPickerItemProps[] | 否 | iOS/Android | 是 |
| label | 在项目文本旁渲染的额外标签 | string | 否 | iOS/Android | 是 |
| labelProps | 额外标签的属性 | TextProps | 否 | iOS/Android | 是 |
| labelStyle | 额外标签的样式 | TextStyle | 否 | iOS/Android | 是 |
| numberOfVisibleRows | 可见行数 | number | 否 | iOS/Android | 是 |
| onChange | 项目变化时的回调 | (item: string | number, index: number) => void | 否 | iOS/Android | 是 |
| separatorsStyle | 分隔符的额外样式 | ViewStyle | 否 | iOS/Android | 是 |
| style | 高度根据 itemHeight * numberOfVisibleRows 计算;容器的自定义样式 | ViewStyle | 否 | iOS/Android | 是 |
| testID | 测试标识符 | string | 否 | iOS/Android | 是 |
| textStyle | 行文本的自定义样式 | TextStyle | 否 | iOS/Android | 是 |
Incubator.Dialog:弹出对话框组件。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| containerProps | 容器的额外属性 | ViewProps | 否 | iOS/Android | 是 |
| containerStyle | Dialog 的容器样式(设置为 {position: 'absolute'}) | ViewStyle | 否 | iOS/Android | 是 |
| direction | 对话框动画/平移的方向(默认为向下) | up |down |left |right | 否 | iOS/Android | 是 |
| headerProps | Dialog 的标题配置(标题、副标题等) | DialogHeaderProps | 否 | iOS/Android | 是 |
| ignoreBackgroundPress | 是否忽略背景点击 | boolean | 否 | iOS/Android | 是 |
| modalProps | 传递给对话框模态的属性 | ModalProps | 否 | iOS/Android | 是 |
| onDismiss | 对话框关闭后触发的回调(动画结束后) | (props?: DialogProps) => void | 否 | iOS/Android | 是 |
| testID | 用于在端到端测试中定位此视图。容器具有原始 ID。支持的内部元素 ID:${TestID}.modal — Modal 的 ID;${TestID}.overlayFadingBackground — 淡入淡出背景的 ID |
string | 否 | iOS/Android | 是 |
| visible | 对话框的可见性 | boolean | 否 | iOS/Android | 是 |
Dialog.Header:弹窗头部组件。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| bottomAccessory | 传入以在副标题下方渲染底部元素 | ReactElement | 否 | iOS/Android | 是 |
| contentContainerStyle | 前导 + 内容 + 尾随组件的样式(不包含底部附件) | ViewProps['style'] | 否 | iOS/Android | 是 |
| leadingAccessory | 传入以渲染前导元素 | ReactElement | 否 | iOS/Android | 是 |
| onPress | 内部内容的点击回调 | () => void | 否 | iOS/Android | 是 |
| showDivider | 显示标题的分隔线 | boolean | 否 | iOS/Android | 是 |
| showKnob | 显示标题的旋钮 | boolean | 否 | iOS/Android | 是 |
| subtitle | 副标题 | string | 否 | iOS/Android | 是 |
| subtitleProps | 副标题的额外属性 | TextProps | 否 | iOS/Android | 是 |
| subtitleStyle | 副标题文本样式 | StyleProp | 否 | iOS/Android | 是 |
| title | 标题 | string | 否 | iOS/Android | 是 |
| titleProps | 标题的额外属性 | TextProps | 否 | iOS/Android | 是 |
| titleStyle | 标题文本样式 | StyleProp | 否 | iOS/Android | 是 |
| topAccessory | 传入以在标题上方渲染顶部元素 | ReactElement | 否 | iOS/Android | 是 |
| trailingAccessory | 传入以渲染尾随元素 | ReactElement | 否 | iOS/Android | 是 |
Incubator.Slider:滑块组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| accessible | 若为 true,组件将启用无障碍功能 |
boolean | 否 | iOS/Android | 是 |
| activeThumbStyle | 拇指处于活动状态(按下时)的样式 | ViewStyle | 否 | iOS/Android | 是 |
| containerStyle | 容器样式 | ViewStyle | 否 | iOS/Android | 是 |
| disableActiveStyling | 若为 true,滑块在按下时不会改变其样式 |
boolean | 否 | iOS/Android | 是 |
| disableRTL | 若为 true,即使应用处于 RTL 模式,滑块仍将保持 LTR 模式 |
boolean | 否 | iOS/Android | 是 |
| disabled | 若为 true,滑块将被禁用,并以禁用颜色显示 |
boolean | 否 | iOS/Android | 是 |
| disabledThumbTintColor | 禁用状态下拇指的颜色 | string | 否 | iOS/Android | 是 |
| enableThumbShadow | 拇指是否显示阴影(仅在 migrate 为 true 时生效) |
boolean | 否 | iOS/Android | 是 |
| initialMaximumValue | 仅当 useRange 为 true 时使用。初始最大值 |
number | 否 | iOS/Android | 是 |
| initialMinimumValue | 仅当 useRange 为 true 时使用。初始最小值 |
number | 否 | iOS/Android | 是 |
| maximumTrackTintColor | 轨道颜色 | string | 否 | iOS/Android | 是 |
| maximumValue | 轨道的最大值 | number | 否 | iOS/Android | 是 |
| minimumTrackTintColor | 从最小值到当前值之间的轨道颜色 | string | 否 | iOS/Android | 是 |
| minimumValue | 轨道的最小值 | number | 否 | iOS/Android | 是 |
| onRangeChange | 范围变化时的回调,返回包含最小值和最大值的值对象 | SliderOnRangeChange | 否 | iOS/Android | 是 |
| onReset | 当重置功能被调用时发出通知的回调 | () => void | 否 | iOS/Android | 是 |
| onSeekEnd | 当滑块完成寻道时发出通知的回调 | () => void | 否 | iOS/Android | 是 |
| onSeekStart | 当滑块开始寻道时发出通知的回调 | () => void | 否 | iOS/Android | 是 |
| onValueChange | 值变化时的回调 | SliderOnValueChange | 否 | iOS/Android | 是 |
| renderTrack | 自定义轨道渲染,替代默认轨道 | () => ReactElement | ReactElement[] | 否 | iOS/Android | 是 |
| step | 滑块的步长值。该值应介于 0 与(最大值 - 最小值)之间 | number | 否 | iOS/Android | 是 |
| testID | 组件测试 ID | string | 否 | iOS/Android | 是 |
| throttleTime | 用于控制 onValueChange 和 onRangeChange 回调的节流时间 |
number | 否 | iOS/Android | 是 |
| thumbHitSlop | 定义触摸事件可起始于拇指外的距离 | number | 否 | iOS/Android | 是 |
| thumbStyle | 拇指样式 | ViewStyle | 否 | iOS/Android | 是 |
| thumbTintColor | 拇指颜色 | string | 否 | iOS/Android | 是 |
| trackStyle | 轨道样式 | ViewStyle | 否 | iOS/Android | 是 |
| useGap | 若为 true,最小值和最大值的拇指将不会重叠 |
boolean | 否 | iOS/Android | 是 |
| useRange | 若为 true,滑块将显示第二个拇指用于设定最小值 |
boolean | 否 | iOS/Android | 是 |
| value | 初始值 | number | 否 | iOS/Android | 是 |
Incubator.Toast:非侵入式弹窗组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| action | 用户的单个操作(showLoader 会覆盖此操作) |
ButtonProps | 否 | iOS/Android | 是 |
| autoDismiss | 自动触发 onDismiss 回调的毫秒数 |
number | 否 | iOS/Android | 是 |
| backgroundColor | Toast 的背景颜色 | string | 否 | iOS/Android | 是 |
| centerMessage | 消息是否应在 Toast 中居中显示 | boolean | 否 | iOS/Android | 是 |
| containerStyle | Toast 容器样式 | ViewStyle | 否 | iOS/Android | 是 |
| elevation | 仅限 Android。自定义高度 | number | 否 | Android | 否 |
| enableHapticFeedback | 是否在 Toast 显示时触发触觉反馈(需要 react-native-haptic-feedback 依赖) |
boolean | 否 | iOS/Android | 是 |
| icon | 在 Toast 左侧渲染的自定义图标 | ImageSourcePropType | 否 | iOS/Android | 是 |
| iconColor | 图标颜色 | string | 否 | iOS/Android | 是 |
| message | Toast 消息 | string | 否 | iOS/Android | 是 |
| messageProps | Toast 消息属性 | TextProps | 否 | iOS/Android | 是 |
| messageStyle | Toast 消息样式 | StyleProp | 否 | iOS/Android | 是 |
| onAnimationEnd | Toast 动画结束时的回调 | (visible?: boolean) => void | 否 | iOS/Android | 是 |
| onDismiss | Toast 关闭时的回调 | () => void | 否 | iOS/Android | 是 |
| position | Toast 的位置,取值为 'top' 或 'bottom' |
'top' | 'bottom' | 否 | iOS/Android | 是 |
| preset | 传入以使用预设 UI | ToastPreset('success' | 'failure' | 'general' | 'offline') | 否 | iOS/Android | 是 |
| renderAttachment | 渲染一个自定义视图,该视图将始终显示在 Toast 的上方或下方(取决于 Toast 的位置),并在 Toast 显示或关闭时随之动画 | () => JSX.Element | undefined | 否 | iOS/Android | 是 |
| showLoader | 是否显示加载器 | boolean | 否 | iOS/Android | 是 |
| style | Toast 样式 | ViewStyle | 否 | iOS/Android | 是 |
| swipeable | 是否支持通过滑动手势关闭 Toast。需要传递 onDismiss 方法来控制可见性 |
boolean | 否 | iOS/Android | 是 |
| testID | 组件测试 ID | string | 否 | iOS/Android | 是 |
| visible | 是否显示或隐藏 Toast | boolean | 否 | iOS/Android | 是 |
| zIndex | Toast 的自定义 zIndex |
number | 否 | iOS/Android | 是 |
Dash:虚线组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| color | 虚线的颜色 | string | 否 | iOS/Android | 是 |
| containerStyle | 容器样式 | ViewStyle | 否 | iOS/Android | 是 |
| gap | 虚线之间的间距 | number | 否 | iOS/Android | 是 |
| length | 虚线的长度 | number | 否 | iOS/Android | 是 |
| style | 虚线的额外样式 | ViewStyle | 否 | iOS/Android | 是 |
| thickness | 虚线的粗细 | number | 否 | iOS/Android | 是 |
| vertical | 虚线是否为垂直方向 | boolean | 否 | iOS/Android | 是 |
ExpandableSection:展开/收起组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| children | 可展开的子内容 | React.ReactNode | 否 | iOS/Android | 是 |
| expanded | ExpandableSection 是否应展开 | boolean | 否 | iOS/Android | 是 |
| onPress | 点击 ExpandableSection 标题时触发 | () => void | 否 | iOS/Android | 是 |
| sectionHeader | 标题元素 | JSX.Element | 否 | iOS/Android | 是 |
| testID | 测试标识符 | string | 否 | iOS/Android | 是 |
| top | 是否应在 sectionHeader 上方展开 |
boolean | 否 | iOS/Android | 是 |
Fader:渐变淡入淡出组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| position | 淡入淡出效果的位置(不同方向) | START | END | TOP | BOTTOM | 否 | iOS/Android | 是 |
| size | 更改淡入淡出视图的大小 | number | 否 | iOS/Android | 是 |
| tintColor | 更改淡入淡出视图的色调颜色 | string | 否 | iOS/Android | 是 |
| visible | 淡入淡出效果是否可见(默认为 true) |
boolean | 否 | iOS/Android | 是 |
Gradient:渐变色组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| color | 渐变的颜色 | string | 否 | iOS/Android | 是 |
| numberOfSteps | 颜色变化的阶数 | number | 否 | iOS/Android | 是 |
| style | 组件的额外样式 | ViewStyle | 否 | iOS/Android | 是 |
| type | 色调 | 亮度 | 饱和度 | GradientTypes | 否 | iOS/Android | 是 |
KeyboardAccessoryView:键盘附件视图。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| kbComponent | 键盘 ID(发送到 KeyboardRegistry 的 componentID) |
string | 否 | iOS/Android | 否 |
| kbInitialProps | 将发送给 KeyboardComponent 的初始属性 | any | 否 | iOS/Android | 否 |
| kbInputRef | 仅限 iOS。实际文本输入的引用(否则键盘可能无法在指示时重置等) | any | 否 | iOS | 否 |
| onHeightChanged | 高度变化时的回调 | (height: number) => void | 否 | iOS/Android | 否 |
| onItemSelected | 当键盘上的项目被按下时触发的回调 | () => void | 否 | iOS/Android | 否 |
| onKeyboardResigned | 键盘关闭后触发的回调 | () => void | 否 | iOS/Android | 否 |
| onRequestShowKeyboard | 若调用 KeyboardRegistry.requestShowKeyboard,将触发的回调 |
() => void | 否 | iOS/Android | 否 |
| renderContent | 在键盘上方渲染的内容 | () => React.ReactElement | 否 | iOS/Android | 是 |
KeyboardAwareInsetsView:用于在使用键盘时添加内边距,避免键盘遮挡部分屏幕。该组件扩展了 KeyboardTrackingView 的属性,此组件仅适用于 iOS。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| KeyboardAwareInsetsView | 在使用键盘时添加内边距,避免键盘遮挡部分屏幕。 | Component | 否 | iOS | 否 |
KeyboardRegistry:用于注册键盘并对键盘执行某些操作。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| addListener | 为回调添加监听器。globalID(字符串)- 包含 componentID 和事件名称的 ID(例如,若 componentID='kb1',则 globalID='kb1.onItemSelected')callback(函数)- 当指定事件发生时触发的回调 |
static function | 否 | iOS/Android | 否 |
| getAllKeyboards | 获取所有键盘 | static function | 否 | iOS/Android | 否 |
| getKeyboard | 获取特定键盘。componentID(字符串)- 键盘的 ID |
static function | 否 | iOS/Android | 否 |
| getKeyboards | 按 ID 获取键盘。componentIDs(字符串[])- 键盘的 ID |
static function | 否 | iOS/Android | 否 |
| notifyListeners | 通知事件已发生。globalID(字符串)- 包含 componentID 和事件名称的 ID(例如,若 componentID='kb1',则 globalID='kb1.onItemSelected')args(对象)- 要发送给监听器的数据 |
static function | 否 | iOS/Android | 否 |
| onItemSelected | 键盘项目被选中时使用的默认事件。componentID(字符串)- 键盘的 ID。args(对象)- 要发送给监听器的数据 |
static function | 否 | iOS/Android | 否 |
| registerKeyboard | 注册新键盘。componentID(字符串)- 键盘的 ID。generator(函数)- 用于创建键盘的函数。params(对象)- 在使用其他方法(即 getKeyboards 和 getAllKeyboards)时返回 |
static function | 否 | iOS/Android | 否 |
| removeListeners | 移除回调监听器。globalID(字符串)- 包含 componentID 和事件名称的 ID(例如,若 componentID='kb1',则 globalID='kb1.onItemSelected') |
static function | 否 | iOS/Android | 否 |
| requestShowKeyboard | 请求显示键盘。componentID(字符串)- 键盘的 ID |
static function | 否 | iOS/Android | 否 |
KeyboardTrackingView:为当前视图及其子视图启用“键盘跟踪”的 UI 组件。通常用于视图内含有 TextField 或 TextInput 的场景,此组件仅适用于 iOS。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| addBottomView | 在 KeyboardAccessoryView 下方添加视图 |
boolean | 否 | iOS | 否 |
| allowHitsOutsideBounds | 允许点击视图边界之外的子视图 | boolean | 否 | iOS | 否 |
| bottomViewColor | 底部视图的颜色 | string | 否 | iOS | 否 |
| manageScrollView | 设置为 false 以关闭插入管理,自行处理 |
boolean | 否 | iOS | 否 |
| ref | 引用 | any | 否 | iOS | 否 |
| requiresSameParentToManageScrollView | 若 manageScrollView 设置为 true 但仍无效,将其设为 true,表示找到的 ScrollView 不正确,需将 KeyboardAccessoryView 与 ScrollView 设为兄弟节点并开启此选项 |
boolean | 否 | iOS | 否 |
| revealKeyboardInteractive | 在负向滚动时显示键盘 | boolean | 否 | iOS | 否 |
| scrollBehavior | 滚动行为(使用 KeyboardTrackingView.scrollBehaviors.NONE | SCROLL_TO_BOTTOM_INVERTED_ONLY | FIXED_OFFSET) |
number | 否 | iOS | 否 |
| scrollToFocusedInput | ScrollView 是否应滚动到聚焦的输入框 |
boolean | 否 | iOS | 否 |
| style | 样式 | ViewStyle | 否 | iOS | 否 |
| trackInteractive | 是否在键盘交互式关闭时保持跟踪(默认为 false)。为什么? 当使用外接键盘(如蓝牙)时,仍会收到键盘事件,且在输入框聚焦时视图只是悬停。此外,若未使用交互式关闭键盘的样式(或视图内无输入框),跟踪键盘并无意义。(由于使用 inputAccessory 来跟踪键盘交互状态,这引入了此问题) |
boolean | 否 | iOS | 否 |
| useSafeArea | 是否处理安全区域 | boolean | 否 | iOS | 否 |
| usesBottomTabs | 是否包含底部标签栏的插入 | boolean | 否 | iOS | 否 |
Overlay:带类型的覆盖视图,继承 Image 组件属性,扩展了 image 组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| overlayColor | 覆盖颜色 | string | no | iOS/Android | yes |
| customOverlayContent | 在图像顶部渲染的自定义覆盖内容 | JSX.Element | no | iOS/Android | yes |
| overlayIntensity | 渐变的强度。 | low |medium |high | no | iOS/Android | yes |
| overlayType | 设置在图像顶部的覆盖类型 | vertical | top | bottom | solid (OverlayTypeType) | no | iOS/Android | yes |
Card:卡片组件,扩展了TouchableOpacity组件,依赖@react-native-community/blur。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| blurOptions | 根据 @react-native-community/blur 库的模糊效果选项(确保 enableBlur 开启) | object | no | iOS/Android | yes |
| borderRadius | 卡片边框半径(将传递给内部 Card.Image 组件) | number | no | iOS/Android | yes |
| containerStyle | 卡片容器的额外样式 | ViewStyle | no | iOS/Android | yes |
| elevation | 仅限 Android。高程值 | number | no | Android | no |
| enableBlur | 仅限 iOS。启用模糊效果 | boolean | no | iOS | yes |
| enableShadow | 卡片是否应有阴影 | boolean | no | iOS/Android | yes |
| height | 卡片自定义高度 | number | string | no | iOS/Android | yes |
| onPress | 卡片按下事件的回调函数 | function | no | iOS/Android | yes |
| row | 内部卡片流动方向是否应为水平 | boolean | no | iOS/Android | yes |
| selected | 添加视觉指示表明卡片被选中 | boolean | no | iOS/Android | yes |
| selectionOptions | 样式化选择指示的自定义选项 | CardSelectionOptions | no | iOS/Android | yes |
| width | 卡片自定义宽度 | number | string | no | iOS/Android | yes |
Card.Image:Card 组件的内部组件(最好是直接子组件),扩展了Image组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| height | 高度 | number | no | iOS/Android | yes |
| position | 图像位置,确定图像的适当弹性度和边框半径(对于 Android)如果作为 Card 父组件的直接子组件渲染,则此属性会自动从 Card 父组件派生 | string[] | no | iOS/Android | yes |
| width | 宽度 | number | no | iOS/Android | yes |
Card.Section:用于在 Card 组件内轻松渲染内容的内部组件,扩展了View组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| backgroundColor | 背景颜色 | string | no | iOS/Android | yes |
| content | 文本内容。示例:content={[{text: 'You’re Invited!', text70: true, grey10: true}]} | ContentType[] | no | iOS/Android | yes |
| contentStyle | 组件的容器样式 | ViewStyle | no | iOS/Android | yes |
| imageProps | 将传递给图像的其他图像属性 | ImageProps | no | iOS/Android | yes |
| imageSource | 提供时将用作背景 | ImageSourcePropType | no | iOS/Android | yes |
| imageStyle | 背景图像的样式 | ImageStyle | no | iOS/Android | yes |
| leadingIcon | 在文本之前渲染的前导图标的图像属性 | ImageProps | no | iOS/Android | yes |
| trailingIcon | 在文本之后渲染的尾随图标的图像属性 | ImageProps | no | iOS/Android | yes |
Carousel:轮播组件,扩展了ScrollView组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| allowAccessibleLayout | 是否为无障碍布局 Carousel | boolean | no | iOS/Android | yes |
| animated | 容器是否应动画化(通过 containerStyle 发送动画样式) | boolean | no | iOS/Android | yes |
| animatedScrollOffset | 传递以附加到 ScrollView 的 Animated.event,以便基于 Carousel 滚动偏移动画元素(传递新的 Animated.ValueXY()) | Animated.ValueXY | no | iOS/Android | yes |
| autoplay | 启用自动在页面之间切换 | boolean | no | iOS/Android | yes |
| autoplayInterval | 在切换到下一页之前等待的时间(毫秒)(需要启用 'autoplay') | number | no | iOS/Android | yes |
| containerMarginHorizontal | Carousel 容器的水平边距 | number | no | iOS/Android | yes |
| containerPaddingVertical | Carousel 容器的垂直内边距(有时在 Android 中需要,当有溢出被截断时)。 | number | no | iOS/Android | yes |
| containerStyle | Carousel 容器样式 | ViewStyle | no | iOS/Android | yes |
| counterTextStyle | 计数器的文本样式 | ViewStyle | no | iOS/Android | yes |
| horizontal | 页面将水平渲染还是垂直渲染 | boolean | no | iOS/Android | yes |
| initialPage | 开始的初始页面 | number | no | iOS/Android | yes |
| itemSpacings | 页面之间的间距 | number | no | iOS/Android | yes |
| loop | 如果为 true,将具有无限滚动(仅适用于水平 Carousel) | boolean | no | iOS/Android | yes |
| onChangePage | 页面更改事件的回调 | (pageIndex, oldPageIndex, info) => void | no | iOS/Android | yes |
| onScroll | 为内部 ScrollView 的 onScroll 事件附加回调 | function | no | iOS/Android | yes |
| pageControlPosition | PageControl 组件的位置 ['over', 'under'],否则不会显示 | PageControlPosition | no | iOS/Android | yes |
| pageControlProps | PageControl 组件属性 | PageControlProps | no | iOS/Android | yes |
| pageHeight | 页面高度(所有页面应具有相同的高度)。 | number | no | iOS/Android | yes |
| pageWidth | 页面宽度(所有页面应具有相同的宽度)。如果传递 'loop' 属性则不起作用 | number | no | iOS/Android | yes |
| pagingEnabled | 将阻止多页面滚动(如果使用 'pageWidth' 属性则不起作用) | boolean | no | iOS/Android | yes |
| showCounter | 是否显示页面计数器(如果使用 'pageWidth' 属性则不起作用) | boolean | no | iOS/Android | yes |
LoaderScreen:全屏显示组件,通常用于页面加载loading,扩展了Activityindicator组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| backgroundColor | 加载器背景的颜色(仅在传递 'overlay' 时) | string | no | iOS/Android | yes |
| containerStyle | 自定义容器样式 | ViewStyle | no | iOS/Android | yes |
| customLoader | 自定义加载器 | React.ReactChild | no | iOS/Android | yes |
| loaderColor | 加载指示器的颜色 | string | no | iOS/Android | yes |
| message | 加载器消息 | string | no | iOS/Android | yes |
| messageStyle | 消息样式 | TextStyle | no | iOS/Android | yes |
| overlay | 将屏幕显示为绝对覆盖 | boolean | no | iOS/Android | yes |
StackAggregator:堆栈聚合器组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| buttonProps | 传递给"显示更少"按钮的属性 | ButtonProps | no | iOS/Android | yes |
| children | 组件子项 | JSX.Element | JSX.Element[] | no | iOS/Android | yes |
| collapsed | 堆栈的初始状态 | boolean | no | iOS/Android | yes |
| containerStyle | 容器样式 | ViewStyle | no | iOS/Android | yes |
| contentContainerStyle | 内容容器样式 | ViewStyle | no | iOS/Android | yes |
| disablePresses | 禁用卡片可按下性的设置 | boolean | no | iOS/Android | yes |
| itemBorderRadius | 项目的边框半径 | number | no | iOS/Android | yes |
| onCollapseChanged | 折叠状态更改的回调(值是折叠状态) | (changed: boolean) => void | no | iOS/Android | yes |
| onCollapseWillChange | 折叠状态将要更改的回调(值是未来的折叠状态) | (changed: boolean) => void | no | iOS/Android | yes |
| onItemPress | 项目按下的回调 | (index: number) => void | no | iOS/Android | yes |
StateScreen:显示全屏组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| ctaLabel | 在 CTA 按钮中显示的文本 | string | no | iOS/Android | yes |
| imageSource | 顶部显示的图像源。使用本地需要的图像 | ImageURISource | no | iOS/Android | yes |
| onCtaPress | CTA 按钮的操作处理程序 | () => void | no | iOS/Android | yes |
| testID | 用于在测试中标识容器 | string | no | iOS/Android | yes |
| title | 显示为标题 | string | no | iOS/Android | yes |
Drawer:抽屉组件,如果您的应用程序与 RNN 配合使用,则您的屏幕必须使用"react-native-gesture-handler"中的gestureHandlerRootHOC 进行包装。请参阅这里。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| bounciness | 抽屉动画的弹性度 | number | no | iOS/Android | yes |
| customValue | 传递给组件并在操作回调中接收的任何类型的自定义值 | any | no | iOS/Android | yes |
| disableHaptic | 是否禁用触觉 | boolean | no | iOS/Android | yes |
| fullLeftThreshold | 左全滑动的阈值(0-1) | number | no | iOS/Android | yes |
| fullRightThreshold | 右全滑动的阈值(0-1) | number | no | iOS/Android | yes |
| fullSwipeLeft | 是否允许左全滑动 | boolean | no | iOS/Android | yes |
| fullSwipeRight | 是否允许右全滑动 | boolean | no | iOS/Android | yes |
| itemsIconSize | 项目的图标大小 | number | no | iOS/Android | yes |
| itemsMinWidth | 设置不同的最小宽度 | number | no | iOS/Android | yes |
| itemsTextStyle | 项目的文本样式 | TextStyle | no | iOS/Android | yes |
| itemsTintColor | 项目的文本和图标色调的颜色 | string | no | iOS/Android | yes |
| leftItem | 从左侧打开时出现的底层项目(单个项目) | ItemProps | no | iOS/Android | yes |
| onDragStart | 当拖动手势开始时调用 | () => any | no | iOS/Android | yes |
| onFullSwipeLeft | 左项目全滑动的回调 | () => void | no | iOS/Android | yes |
| onFullSwipeRight | 右项目全滑动的回调 | () => void | no | iOS/Android | yes |
| onSwipeableWillClose | 关闭操作的回调 | () => void | no | iOS/Android | yes |
| onSwipeableWillOpen | 打开操作的回调 | () => void | no | iOS/Android | yes |
| onToggleSwipeLeft | 左项目切换滑动的回调 | () => {rowWidth, leftWidth, dragX, resetItemPosition} | no | iOS/Android | yes |
| onWillFullSwipeLeft | 左项目全滑动之前的回调 | () => void | no | iOS/Android | yes |
| onWillFullSwipeRight | 右项目全滑动之前的回调 | () => void | no | iOS/Android | yes |
| rightItems | 从右侧打开时出现的底层项目 | ItemProps[] | no | iOS/Android | yes |
| style | 组件的样式 | ViewStyle | no | iOS/Android | yes |
| testID | 用于端到端测试的测试 ID | string | no | iOS/Android | yes |
| useNativeAnimations | 在本机执行动画 | boolean | no | iOS/Android | yes |
GridList:网格列表组件,扩展了FlatList组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| containerWidth | 当您想要使用自定义容器宽度进行计算时传递 | number | no | iOS/Android | yes |
| contentContainerStyle | 自定义内容容器样式 | ScrollView[ contentContainerStyle ] | no | iOS/Android | yes |
| itemSpacing | 每个项目之间的间距 | number | no | iOS/Android | yes |
| keepItemSize | 当方向更改时是否保持项目的初始大小,在这种情况下将自动计算适当的列数。 | boolean | no | iOS/Android | yes |
| listPadding | 列表内边距(用于项目大小计算) | number | no | iOS/Android | yes |
| maxItemWidth | 允许响应式项目宽度到最大项目宽度 | number | no | iOS/Android | yes |
| numColumns | 一行中显示的项目数(传递 maxItemWidth 时忽略) | number | no | iOS/Android | yes |
GridListItem:单个网格视图/列表项组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| alignToStart | 内容是否应对齐到起始位置 | boolean | no | iOS/Android | yes |
| containerProps | 传递给可触摸容器的属性 | TouchableOpacityProps | ViewProps | no | iOS/Android | yes |
| containerStyle | 自定义容器样式 | ViewStyle | no | iOS/Android | yes |
| description | 描述内容文本 | string | React.ReactElement | no | iOS/Android | yes |
| descriptionColor | 描述内容颜色 | string | no | iOS/Android | yes |
| descriptionLines | 描述内容行数 | number | no | iOS/Android | yes |
| descriptionTypography | 描述内容排版 | string | no | iOS/Android | yes |
| horizontalAlignment | 内容水平对齐方式 | HorizontalAlignment | no | iOS/Android | yes |
| imageProps | 用于渲染图像项目的图像属性对象 | ImageProps | no | iOS/Android | yes |
| itemSize | 项目尺寸 | number | ImageSize | no | iOS/Android | yes |
| onPress | 项目的点击处理函数 | TouchableOpacityProps ['onPress'] | no | iOS/Android | yes |
| overlayText | 在项目内部渲染标题、副标题和描述 | boolean | no | iOS/Android | yes |
| overlayTextContainerStyle | 内联文本的自定义容器样式 | ViewStyle | no | iOS/Android | yes |
| renderCustomItem | 在 GridView 中渲染的自定义 GridListItem | () => React.ReactElement | no | iOS/Android | yes |
| renderOverlay | 在图像顶部渲染覆盖层 | () => React.ReactElement | no | iOS/Android | yes |
| subtitle | 副标题内容文本 | string | React.ReactElement | no | iOS/Android | yes |
| subtitleColor | 副标题内容颜色 | string | no | iOS/Android | yes |
| subtitleLines | 副标题内容行数 | number | no | iOS/Android | yes |
| subtitleTypography | 副标题内容排版 | string | no | iOS/Android | yes |
| testID | 组件测试标识符 | string | no | iOS/Android | yes |
| title | 标题内容文本 | string | React.ReactElement | no | iOS/Android | yes |
| titleColor | 标题内容颜色 | string | no | iOS/Android | yes |
| titleLines | 标题内容行数 | number | no | iOS/Android | yes |
| titleTypography | 标题内容排版 | string | no | iOS/Android | yes |
GridView:网格视图组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| itemSpacing | 每个项目之间的间距 | number | no | iOS/Android | yes |
| items | 基于 GridListItem 属性的项目列表 | GridListItemProps[] | no | iOS/Android | yes |
| keepItemSize | 当方向改变时是否保持项目的初始尺寸,此时将自动计算合适的列数。 | boolean | no | iOS/Android | yes |
| lastItemLabel | 最后一个项目的覆盖标签 | string | number | no | iOS/Android | yes |
| lastItemOverlayColor | 最后一个项目的覆盖标签颜色 | string | no | iOS/Android | yes |
| numColumns | 每行显示的项目数量 | number | no | iOS/Android | yes |
| renderCustomItem | 用于渲染自定义项目的回调 | (item: GridListItemProps) => React.ReactElement | no | iOS/Android | yes |
| viewWidth | 指定网格视图的宽度(可加快加载速度) | number | no | iOS/Android | yes |
ListItem:列表中的列表项组件,该组件继承了 TouchableOpacity 的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| containerElement | 包装 ListItem 的容器元素 | React.ComponentType <ListItemProps | TouchableOpacityProps> | no | iOS/Android | yes |
| containerStyle | 顶部容器的额外样式 | ViewStyle | no | iOS/Android | yes |
| height | 列表项高度 | ViewStyle['height'] | no | iOS/Android | yes |
| onLongPress | 长按项目时的回调 | () => void | no | iOS/Android | yes |
| onPress | 点击项目时的回调 | () => void | no | iOS/Android | yes |
| style | 内部元素样式 | ViewStyle | no | iOS/Android | yes |
| testID | 用于端到端测试的测试 ID | string | no | iOS/Android | yes |
| underlayColor | 内部元素按下时的背景颜色 | string | no | iOS/Android | yes |
ListItem.Part:用于 ListItem 内部布局的列表项子组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| column | 此部分内容方向是否为列 | boolean | no | iOS/Android | yes |
| containerStyle | 容器样式 | ViewStyle | no | iOS/Android | yes |
| left | 此部分内容是否左对齐 | boolean | no | iOS/Android | yes |
| middle | 此部分内容是否平均分布 | boolean | no | iOS/Android | yes |
| right | 此部分内容是否右对齐 | boolean | no | iOS/Android | yes |
| row | 此部分内容方向是否为行 | boolean | no | iOS/Android | yes |
SortableGridList:可排序网格列表组件,该组件继承了 GridList 组件的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| data | 不要在 'onOrderChange' 中更新 'data'(即每次顺序变化时);仅在数据项本身发生变化时更新(即添加或删除项目)。数据项需包含 id 属性作为唯一标识符 | any[] & {id: string} | no | iOS/Android | yes |
| extraData | 传递任何需要触发重新渲染的额外数据 | any | no | iOS/Android | yes |
| onOrderChange | 顺序变化回调 | (newData: T[], newOrder: ItemsOrder) => void | no | iOS/Android | yes |
| renderItem | 自定义项目渲染回调 | FlatListProps ['renderItem'] | no | iOS/Android | yes |
SortableList:可排序列表组件,该组件继承了 FlatList 组件的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| data | 不要在 'onOrderChange' 中更新 'data'(即每次顺序变化时);仅在数据项本身发生变化时更新(即添加或删除项目)。列表数据需包含 id 属性作为唯一标识符。 | ItemT[] (ItemT extends {id: string}) | no | iOS/Android | yes |
| enableHaptic | 是否启用触觉反馈。(请注意,从某个未知版本开始,react-native-haptic-feedback 不再支持 Android 上的部分触觉类型,使用 1.8.2 版本可确保正常工作) | boolean | no | iOS/Android | yes |
| itemProps | 项目的额外属性。 | {margins?: {marginTop?: number; marginBottom?: number; marginLeft?: number; marginRight?: number}} | no | iOS/Android | yes |
| onOrderChange | 获取新顺序(或交换项目)的回调。 | (data: ItemT[]) => void | no | iOS/Android | yes |
| scale | 拖动时项目的缩放比例。 | number | no | iOS/Android | yes |
Timeline:时间线组件,该组件继承了 View 组件的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| backgroundColor | 项目的背景颜色 | string | no | iOS/Android | yes |
| bottomLine | 底部线的属性 | LineProps | no | iOS/Android | yes |
| point | 点的属性 | PointProps | no | iOS/Android | yes |
| renderContent | 渲染到时间线指示器右侧的自定义内容 | any | no | iOS/Android | yes |
| state | 时间线的状态,会影响指示器的颜色(使用静态值 'states') | current | next | error |success | no | iOS/Android | yes |
| testID | 用于端到端测试的测试 ID | string | no | iOS/Android | yes |
| topLine | 顶部线的属性 | LineProps | no | iOS/Android | yes |
AnimatedImage:图像加载完成后以动画方式淡入的图像组件,该组件继承了 Image 组件的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| animationDuration | 图像加载时淡入动画的持续时间 | number | no | iOS/Android | yes |
| containerStyle | 容器的额外间距样式 | ViewStyle | no | iOS/Android | yes |
| loader | 图像加载时渲染的组件 | JSX.element | no | iOS/Android | yes |
| onLoadStart | 加载开始回调 | () => void | no | iOS/Android | yes |
AnimatedScanner:该组件继承了 Animated.View 组件的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| backgroundColor | 背景颜色 | string | no | iOS/Android | yes |
| containerStyle | 组件的容器样式 | ViewStyle | no | iOS/Android | yes |
| duration | 当前中断的持续时间(可在中断之间调整) | number | no | iOS/Android | yes |
| hideScannerLine | 是否隐藏扫描线 | boolean | no | iOS/Android | yes |
| onBreakpoint | 断点回调 | ({progress, isDone}) => void | no | iOS/Android | yes |
| opacity | 不透明度 | number | no | iOS/Android | yes |
| progress | 0 到 100 之间的动画值 | number | no | iOS/Android | yes |
| testID | 用作测试标识符 | string | no | iOS/Android | yes |
Avatar:头像组件,该组件继承了 TouchableOpacity 和 Image 组件的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| animate | 当 Avatar 图像加载时添加淡入动画 | boolean | no | iOS/Android | yes |
| autoColorsConfig | 传入此项以根据名称推断 backgroundColor | AutoColorsProps | no | iOS/Android | yes |
| backgroundColor | Avatar 的背景颜色 | string | no | iOS/Android | yes |
| badgePosition | Avatar 上徽章的位置 | TOP_RIGHT |TOP_LEFT |BOTTOM_RIGHT |BOTTOM_LEFT | no | iOS/Android | yes |
| badgeProps | 传递给 Badge 组件的徽章属性 | BadgeProps | no | iOS/Android | yes |
| containerStyle | 容器的额外间距样式 | ViewStyle | no | iOS/Android | yes |
| customRibbon | 自定义丝带 | JSX.Element | no | iOS/Android | yes |
| imageProps | 图像属性对象 | ImageProps | no | iOS/Android | yes |
| imageStyle | 用于通过组件传递额外样式属性的图像样式对象 | ImageStyle | no | iOS/Android | yes |
| label | 可以是首字母的标签 | string | no | iOS/Android | yes |
| labelColor | 标签颜色 | string | no | iOS/Android | yes |
| name | 头像用户的名称。如果未提供标签,将根据名称生成首字母。autoColorsConfig 将使用名称创建 Avatar 的背景颜色。 | string | no | iOS/Android | yes |
| onImageLoadEnd | 图像(uri)加载成功或失败时的监听回调(等同于 Image.onLoadEnd())。 | ImagePropsBase ['onLoadEnd'] | no | iOS/Android | yes |
| onImageLoadError | 图像(uri)加载失败时的监听回调(等同于 Image.onError())。 | ImagePropsBase ['onError'] | no | iOS/Android | yes |
| onImageLoadStart | 图像(uri)开始加载时的监听回调(等同于 Image.onLoadStart())。 | ImagePropsBase ['onLoadStart'] | no | iOS/Android | yes |
| onPress | 点击处理函数 | (props: any) => void | no | iOS/Android | yes |
| ribbonLabel | 显示在头像上的丝带标签 | string | no | iOS/Android | yes |
| ribbonLabelStyle | 丝带标签的自定义样式 | TextStyle | no | iOS/Android | yes |
| ribbonStyle | 丝带的自定义样式 | ViewStyle | no | iOS/Android | yes |
| size | Avatar 的自定义尺寸 | number | no | iOS/Android | yes |
| source | 图像来源(外部或来自资源) | ImageSourcePropType | no | iOS/Android | yes |
| testID | 测试标识符 | string | no | iOS/Android | yes |
| useAutoColors | 对名称(或标签)进行哈希以获取颜色,从而使每个名称对应特定颜色。默认为 false。 | boolean | no | iOS/Android | yes |
| labelEllipsizeMode | 标签的省略号模式,默认为 clip | TextProps['ellipsizeMode'] | no | iOS/Android | yes |
| accessibilityLabel | 作为字符串对象的无障碍标签 | string | no | iOS/Android | yes |
Icon:图标组件,该组件继承了 Image 组件的属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| assetGroup | 资源组,默认为 icons | string | no | iOS/Android | yes |
| assetName | 如提供,图标源将由资源名称驱动 | string | no | iOS/Android | yes |
| recorderTag | 记录器标签 | 'mask' |'unmask' | no | iOS/Android | yes |
| size | 图标大小 | number | no | iOS/Android | yes |
| supportRTL | 图像是否应在 RTL 本地环境中水平翻转 | boolean | no | iOS/Android | yes |
| tintColor | 图标色调 | string | no | iOS/Android | yes |
Image:图片组件,该组件扩展了Image组件属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| aspectRatio | 图像的宽高比 | number | no | iOS/Android | yes |
| assetGroup | 资源组,默认为 icons | string | no | iOS/Android | yes |
| assetName | 如提供,图像源将由资源名称驱动 | string | no | iOS/Android | yes |
| cover | 将图像显示为封面,全宽图像(根据宽高比,默认:16:8) | boolean | no | iOS/Android | yes |
| customOverlayContent | 渲染带有自定义内容的覆盖层 | JSX.Element | no | iOS/Android | yes |
| errorSource | 错误情况下的默认图像源 | ImageSourcePropType | no | iOS/Android | yes |
| imageId | 可在 sourceTransformer 逻辑中使用的 imageId | string | no | iOS/Android | yes |
| overlayColor | 为覆盖层传递自定义颜色 | string | no | iOS/Android | yes |
| overlayIntensity | 覆盖强度类型 | LOW |MEDIUM |HIGH | no | iOS/Android | yes |
| overlayType | 图像必须具有适当的大小,设置在图像顶部的覆盖层类型 | VERTICAL |TOP |BOTTOM |SOLID | no | iOS/Android | yes |
| recorderTag | 记录器标签 | 'mask' | 'unmask' | no | iOS/Android | yes |
| sourceTransformer | 用于操作图像源的自定义源转换处理程序(非常适合大小控制) | (props: any) => ImageSourcePropType | no | iOS/Android | yes |
| supportRTL | 图像是否应在 RTL 本地环境中水平翻转 | boolean | no | iOS/Android | yes |
| tintColor | 资源色调 | string | no | iOS/Android | yes |
| useBackgroundContainer | 为图像使用容器,这可以解决在需要对同一视图执行动画时 Android 上的问题;即 Android 上与动画相关的崩溃 | boolean | no | iOS/Android | yes |
Marquee:滑动文本组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| containerStyle | 自定义容器样式 | ViewProps['style'] | no | iOS/Android | no |
| direction | 滑动方向 | MarqueeDirections | no | iOS/Android | no |
| duration | 滑动动画持续时间 | number | no | iOS/Android | no |
| label | 滑动标签 | string | no | iOS/Android | no |
| labelStyle | 滑动标签样式 | TextProps['style'] | no | iOS/Android | no |
| numberOfReps | 滑动动画重复次数 | number | no | iOS/Android | no |
ProgressiveImage:带动画的图像组件,该组件扩展了AnimatedImage组件属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| thumbnailSource | 全尺寸图像加载时显示的小缩略图源 | ImageSource | no | iOS/Android | yes |
PageControl:页面指示器组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| color | 所选页面点以及(如果未传递 inactiveColor)未选页面边框的颜色 | string | no | iOS/Android | yes |
| containerStyle | 顶部容器的额外样式 | ViewStyle | no | iOS/Android | yes |
| currentPage | 当前页面的从零开始的索引 | number | no | iOS/Android | yes |
| enlargeActive | 是否放大活动页面指示器。当 limitShownPages 生效时无关 | boolean | no | iOS/Android | yes |
| inactiveColor | 未选页面点和未选页面边框的颜色 | string | no | iOS/Android | yes |
| limitShownPages | 限制显示的页面指示器数量。在此状态下 enlargeActive 属性被禁用,当设置为 true 时最多显示 5 个。仅当 numOfPages > 5 时相关 | boolean | no | iOS/Android | yes |
| numOfPages | 总页数 | number | no | iOS/Android | yes |
| onPagePress | 点击页面指示器的操作处理程序 | (index: number) => void | no | iOS/Android | yes |
| size | 页面指示器的大小。当设置 limitShownPages 时,中等大小将是 size 的 2/3,小大小将是 size 的 1/3。另一种选择是发送数组 [smallSize, mediumSize, largeSize] | number | [number, number, number] | no | iOS/Android | yes |
| spacing | 兄弟页面指示器之间的间距 | number | no | iOS/Android | yes |
| testID | 用于在测试中标识页面控件 | string | no | iOS/Android | yes |
TabController:具有延迟加载机制的选项卡控制器组件,该组件基于 react-native-gesture-handler,使用 react-native-navigation 时,请确保使用 gestureHandlerRootHOC 包裹屏幕。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| asCarousel | 当使用 TabController.PageCarousel 时,应开启此选项 | boolean | no | iOS/Android | yes |
| carouselPageWidth | 为自定义轮播页面宽度传递 | number | no | iOS/Android | yes |
| initialIndex | 初始选中的索引 | number | no | iOS/Android | yes |
| items | 标签栏项目列表 | TabControllerItemProps [] | no | iOS/Android | yes |
| onChangeIndex | 当索引更改时的回调(不会在忽略的项目上调用) | (index: number, prevIndex: number | null) => void | no | iOS/Android | yes |
| nestedInScrollView | 当 TabController 渲染在 ScrollView 内部时传递(带有标题) | boolean | no | iOS/Android | yes |
TabController.PageCarousel:TabController 的 PageCarousel 组件,该组件扩展了ScrollView组件属性。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| TabController.PageCarousel | TabController 的 PageCarousel 组件,您必须将 asCarousel 标志传递给 TabController,并在 PageCarousel 内部渲染您的 TabPages | Component | no | iOS/Android | yes |
TabController.TabBar:TabController 的 TabBar 组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| activeBackgroundColor | 标签项按下时应用的背景颜色 | string | no | iOS/Android | yes |
| backgroundColor | TabBar 背景颜色 | string | no | iOS/Android | yes |
| centerSelected | 传递以居中选中项目 | boolean | no | iOS/Android | yes |
| containerStyle | 容器的额外样式 | ViewStyle | no | iOS/Android | yes |
| containerWidth | TabBar 容器宽度 | number | no | iOS/Android | yes |
| enableShadow | 显示标签栏底部阴影 | boolean | no | iOS/Android | yes |
| height | 标签栏高度 | number | no | iOS/Android | yes |
| iconColor | 图标色调颜色 | string | no | iOS/Android | yes |
| indicatorInsets | 指示器内边距 | number | no | iOS/Android | yes |
| indicatorStyle | 选中指示器的自定义样式 | ViewStyle | no | iOS/Android | yes |
| labelColor | 默认标签颜色 | string | no | iOS/Android | yes |
| labelStyle | 自定义标签样式 | TextStyle | no | iOS/Android | yes |
| selectedIconColor | 图标选中色调颜色 | string | no | iOS/Android | yes |
| selectedLabelColor | 选中标签颜色 | string | no | iOS/Android | yes |
| selectedLabelStyle | 自定义选中标签样式 | TextStyle | no | iOS/Android | yes |
| shadowStyle | 自定义阴影样式 | ViewStyle | no | iOS/Android | yes |
| spreadItems | 标签栏是否应展开 | boolean | no | iOS/Android | yes |
| testID | 组件测试 ID | string | no | iOS/Android | yes |
| uppercase | 是否将文本更改为大写 | boolean | no | iOS/Android | yes |
TabController.TabBarItem:TabController 的 TabBarItem 组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| activeBackgroundColor | TouchableOpacity 按下时应用的背景颜色 | string | no | iOS/Android | yes |
| activeOpacity | 按下标签时的活动不透明度 | number | no | iOS/Android | yes |
| backgroundColor | 为标签栏项应用背景颜色 | string | no | iOS/Android | yes |
| badge | 在项目标签旁边显示的徽章组件属性 | BadgeProps | no | iOS/Android | yes |
| icon | 标签的图标 | number | no | iOS/Android | yes |
| iconColor | 图标色调颜色 | string | no | iOS/Android | yes |
| ignore | 忽略标签按下 | boolean | no | iOS/Android | yes |
| label | 标签的文本 | string | no | iOS/Android | yes |
| labelColor | 默认标签颜色 | string | no | iOS/Android | yes |
| labelProps | 传递给标签文本元素的额外标签属性 | TextProps | no | iOS/Android | yes |
| labelStyle | 自定义标签样式 | TextStyle | no | iOS/Android | yes |
| leadingAccessory | 传递以渲染前导元素 | ReactElement | no | iOS/Android | yes |
| onPress | 按下标签时的回调 | (index: number) => void | no | iOS/Android | yes |
| selectedIconColor | 图标选中色调颜色 | string | no | iOS/Android | yes |
| selectedLabelColor | 选中标签颜色 | string | no | iOS/Android | yes |
| selectedLabelStyle | 自定义选中标签样式 | TextStyle | no | iOS/Android | yes |
| style | 传递自定义样式 | ViewStyle | no | iOS/Android | yes |
| testID | 用作测试标识符 | string | no | iOS/Android | yes |
| trailingAccessory | 传递以渲染尾随元素 | ReactElement | no | iOS/Android | yes |
| uppercase | 是否将文本更改为大写 | boolean | no | iOS/Android | yes |
| width | 项目的固定宽度 | number | no | iOS/Android | yes |
TabController.TabPage:TabController 的 TabPage 组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| index | TabPage 的索引 | number | no | iOS/Android | yes |
| lazy | 此页面是否应延迟加载 | boolean | no | iOS/Android | yes |
| lazyLoadTime | 延迟加载完成前等待的时间(适合显示加载器屏幕) | number | no | iOS/Android | yes |
| renderLoading | 延迟加载时渲染自定义加载页面 | () => JSX.Element | no | iOS/Android | yes |
| testID | 组件测试 ID | string | no | iOS/Android | yes |
Wizard:向导组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| activeConfig | 活动步骤的配置(参见 Wizard.Step.propTypes) | WizardStepProps | no | iOS/Android | no |
| activeIndex | 活动步骤的索引 | number | no | iOS/Android | no |
| containerStyle | 添加或覆盖容器的样式 | ViewStyle | no | iOS/Android | no |
| onActiveIndexChanged | 当活动步骤更改时调用的回调(即单击了某个步骤)。新的 activeIndex 将是回调的输入 | (index: number) => void | no | iOS/Android | no |
| testID | 组件测试 ID | string | no | iOS/Android | no |
Wizard.Step:向导组件中的 Step 组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| accessibilityInfo | 在无障碍模式下读取的额外文本 | string | no | iOS/Android | no |
| circleBackgroundColor | 圆圈的背景颜色 | string | no | iOS/Android | no |
| circleColor | 圆圈的颜色 | string | no | iOS/Android | no |
| circleSize | 步骤圆圈的大小(直径) | number | no | iOS/Android | no |
| color | 步骤索引的颜色(或提供图标时的图标颜色) | string | no | iOS/Android | no |
| connectorStyle | 连接器的额外样式 | ViewStyle | no | iOS/Android | no |
| enabled | 步骤是否应启用 | boolean | no | iOS/Android | no |
| icon | 替换(默认)索引的图标 | ImageProps | no | iOS/Android | no |
| indexLabelStyle | 索引标签的额外样式(当未提供图标时) | TextStyle | no | iOS/Android | no |
| label | 项目的标签 | string | no | iOS/Android | no |
| labelStyle | 标签的额外样式 | TextStyle | no | iOS/Android | no |
| state | 步骤的状态(Wizard.States.X) | WizardStepStates | no | iOS/Android | no |
ActionSheet:弹窗选择组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| cancelButtonIndex | 表示取消操作选项的索引(将显示为分离的底部粗体按钮) | number | 否 | iOS/Android | 否 |
| containerStyle | 添加或覆盖操作表的样式(包装标题和操作) | ViewStyle | 否 | iOS/Android | 是 |
| destructiveButtonIndex | 表示破坏性操作选项的索引(将显示红色文本。通常用于删除或中止操作) | number | 否 | iOS/Android | 否 |
| dialogStyle | 添加或覆盖包装操作表的对话框样式 | ViewStyle | 否 | iOS/Android | 是 |
| message | 操作表的消息 | string | 否 | iOS/Android | 否 |
| onDismiss | 关闭操作表时调用(通常用于将 'visible' 属性设置为 false) | DialogProps['onDismiss'] | 否 | iOS/Android | 是 |
| onModalDismissed | 仅限 iOS,仅模态。模态关闭后调用一次 | DialogProps ['onDialogDismissed'] | 否 | iOS | 是 |
| options | 操作表的选项列表,遵循 Button 属性类型(提供 'label' 字符串和 'onPress' 函数) | Array | 否 | iOS/Android | 是 |
| optionsStyle | 添加或覆盖选项列表的样式 | ViewStyle | 否 | iOS/Android | 是 |
| renderAction | 您需要调用 'onOptionPress' 以便选项的 'onPress' 被调用。渲染自定义操作 | ( option: ButtonProps, index: number, onOptionPress: ActionSheetOnOptionPress ) => JSX.Element | 否 | iOS/Android | 是 |
| renderTitle | 渲染自定义标题 | () => JSX.Element | 否 | iOS/Android | 是 |
| showCancelButton | 当传递时(仅与 useNativeIOS 一起使用),将在底部显示取消按钮(覆盖 cancelButtonIndex) | boolean | 否 | iOS/Android | 否 |
| testID | 用于端到端测试的测试 ID | string | 否 | iOS/Android | 是 |
| title | 如果未传递 'title' 和 'message',则根本不会渲染标题视图。操作表的标题 | string | 否 | iOS/Android | 是 |
| useNativeIOS | 是否应为 iOS 使用原生操作表 | boolean | 否 | iOS/Android | 否 |
| useSafeArea | 在 iOS 中,使用安全区域,以防组件附加到底部 | boolean | 否 | iOS/Android | 是 |
| visible | 是否显示操作表 | boolean | 否 | iOS/Android | 是 |
Dialog:弹窗组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| containerStyle | 组件的容器样式 | ViewStyle | 否 | iOS/Android | 是 |
| height | 高度 | string |number | 否 | iOS/Android | 是 |
| ignoreBackgroundPress | 是否忽略背景按下 | boolean | 否 | iOS/Android | 是 |
| onDialogDismissed | 对话框完全关闭后调用 | (props: any) => void | 否 | iOS/Android | 是 |
| onDismiss | 点击背景时调用 | (props?: any) => void | 否 | iOS/Android | 是 |
| overlayBackgroundColor | 覆盖背景的颜色 | string | 否 | iOS/Android | 是 |
| panDirection | 允许平移的方向 | UP |DOWN |LEFT |RIGHT | 否 | iOS/Android | 是 |
| pannableHeaderProps | 将传递给可平移标题的属性 | any | 否 | iOS/Android | 是 |
| renderPannableHeader | 如果添加此项,则只有标题是可平移的。属性将传递给 'renderPannableHeader'。对于可滚动内容(对话框的子项) | (props: any) => JSX.Element | 否 | iOS/Android | 是 |
| testID | 用于端到端测试的测试 ID | string | 否 | iOS/Android | 是 |
| useSafeArea | 在 iOS 中,使用安全区域,以防组件附加到底部 | boolean | 否 | iOS/Android | 是 |
| visible | 控制组件的可见性 | boolean | 否 | iOS/Android | 是 |
| width | 宽度 | string | number | 否 | iOS/Android | 是 |
FeatureHighlight:功能发现组件,FeatureHighlight 组件必须是 render() 返回的根视图的直接子级,如果要突出显示的元素没有样式属性,请添加 'style={{opacity: 1}}' 以便 Android 操作系统可以检测到它,FeatureHighlight 使用 native 库,你需要引入它。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| borderColor | 高亮元素周围边框的颜色 | string | 否 | iOS/Android | 是 |
| borderRadius | 高亮元素周围边框角的边框半径 | number | 否 | iOS/Android | 是 |
| borderWidth | 高亮元素周围边框的宽度 | number | 否 | iOS/Android | 是 |
| confirmButtonProps | 将传递给关闭按钮的属性 | ButtonProps | 否 | iOS/Android | 是 |
| getTarget | 提取要高亮元素的引用的回调 | () => any | 否 | iOS/Android | 是 |
| highlightFrame | 要高亮区域的框架 {x, y, width, height} | HighlightFrame | 否 | iOS/Android | 是 |
| innerPadding | 高亮框架围绕高亮元素框架的内边距(仅在 'getTarget' 中传递引用时) | number | 否 | iOS/Android | 是 |
| message | 要显示的消息 | string | 否 | iOS/Android | 是 |
| messageNumberOfLines | 消息的最大行数 | number | 否 | iOS/Android | 是 |
| messageStyle | 消息文本样式 | TextStyle | 否 | iOS/Android | 是 |
| minimumRectSize | Android API 21+,并且仅在 'getTarget' 中传递引用时。高亮组件的最小大小 | RectSize | 否 | iOS/Android | 是 |
| onBackgroundPress | 背景按下时调用 | TouchableWithoutFeedbackProps ['onPress'] | 否 | iOS/Android | 是 |
| overlayColor | 内容背景的颜色(通常包含 alpha 透明度) | string | 否 | iOS/Android | 是 |
| pageControlProps | PageControl 组件的属性 | PageControlProps | 否 | iOS/Android | 是 |
| testID | 用于端到端测试的测试 ID | string | 否 | iOS/Android | 是 |
| textColor | 内容文本的颜色 | string | 否 | iOS/Android | 是 |
| title | 要显示的内容标题 | string | 否 | iOS/Android | 是 |
| titleNumberOfLines | 标题的最大行数 | number | 否 | iOS/Android | 是 |
| titleStyle | 标题文本样式 | TextStyle | 否 | iOS/Android | 是 |
| visible | 确定是否呈现功能高亮组件 | boolean | 否 | iOS/Android | 是 |
FloatingButton:具有渐变的悬浮按钮。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| bottomMargin | 按钮的底部边距,如果传递了辅助按钮则为辅助按钮的底部边距 | number | 否 | iOS/Android | 是 |
| button | Button 组件的属性 | ButtonProps | 否 | iOS/Android | 是 |
| buttonLayout | 按钮布局方向:垂直或水平 | FloatingButtonLayouts | 否 | iOS/Android | 是 |
| duration | 按钮动画的持续时间(显示/隐藏) | number | 否 | iOS/Android | 是 |
| fullWidth | 仅与垂直布局相关。按钮是否获取容器的全宽 | boolean | 否 | iOS/Android | 是 |
| hideBackgroundOverlay | 是否显示背景覆盖 | boolean | 否 | iOS/Android | 是 |
| secondaryButton | 辅助 Button 组件的属性 | ButtonProps | 否 | iOS/Android | 是 |
| testID | 为主按钮使用 testID.button 或为辅助按钮使用 testID.secondaryButton。用于端到端测试的测试 ID |
string | 否 | iOS/Android | 是 |
| visible | 组件是否可见 | boolean | 否 | iOS/Android | 是 |
| withoutAnimation | 是否在没有动画的情况下显示/隐藏按钮 | boolean | 否 | iOS/Android | 是 |
Modal:模态框组件,该组件扩展了 Modal 组件属性。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| accessibilityLabel | 覆盖屏幕阅读器在用户与元素交互时读取的文本。默认情况下,标签是通过遍历所有子项并累积所有由空格分隔的文本节点来构建的。 | string | 否 | iOS/Android | 是 |
| blurView | 用作 BlurView 的自定义视图而不是默认视图 | JSX.Element | 否 | iOS/Android | 是 |
| enableModalBlur | 仅限 iOS。透明时模糊模态背景 | boolean | 否 | iOS | 是 |
| onBackgroundPress | 允许在单击其背景时关闭模态 | (event: GestureResponderEvent) => void | 否 | iOS/Android | 是 |
| overlayBackgroundColor | 覆盖的背景颜色 | string | 否 | iOS/Android | 是 |
| testID | 模态的端到端测试标识符 | string | 否 | iOS/Android | 是 |
| useGestureHandlerRootView | 仅限 Android。应添加 GestureHandlerRootView | boolean | 否 | Android | 否 |
Modal.TopBar:模态框的 TopBar 组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| cancelButtonProps | 取消操作属性 | ButtonProps | 否 | iOS/Android | 是 |
| cancelIcon | 取消操作图标 | ImageSource | 否 | iOS/Android | 是 |
| cancelLabel | 取消操作标签 | string | 否 | iOS/Android | 是 |
| containerStyle | TopBar 容器的样式 | ViewStyle | 否 | iOS/Android | 是 |
| doneButtonProps | 完成操作属性 | ButtonProps | 否 | iOS/Android | 是 |
| doneIcon | 完成操作图标 | ImageSource | 否 | iOS/Android | 是 |
| doneLabel | 完成操作标签 | string | 否 | iOS/Android | 是 |
| includeStatusBar | 是否包括状态栏(高度计算) | boolean | 否 | iOS/Android | 是 |
| leftButtons | 在顶部栏左侧渲染的按钮 | topBarButtonProp| topBarButtonProp[] | 否 | iOS/Android | 是 |
| onCancel | 取消操作回调 | (props?: any) => void | 否 | iOS/Android | 是 |
| onDone | 完成操作回调 | (props?: any) => void | 否 | iOS/Android | 是 |
| rightButtons | 在顶部栏右侧渲染的按钮 | topBarButtonProp | topBarButtonProp[] | 否 | iOS/Android | 是 |
| subtitle | 在顶部栏标题下方显示的副标题 | string | 否 | iOS/Android | 是 |
| subtitleStyle | 副标题自定义样式 | TextStyle | 否 | iOS/Android | 是 |
| title | 在顶部栏中心显示的标题 | string | 否 | iOS/Android | 是 |
| titleStyle | 标题自定义样式 | TextStyle | 否 | iOS/Android | 是 |
Toast:非中断式弹窗组件,请考虑转向我们新的 Toast 实现并使用 Incubator.Toast 代替。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| Toast | 可自定义的 Toast 组件 | Component | 否 | iOS/Android | 是 |
Badge:圆形彩色徽章组件。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| backgroundColor | 背景颜色 | string | 否 | iOS/Android | 是 |
| borderColor | 徽章周围边框的颜色 | ImageStyle ['borderColor'] | 否 | iOS/Android | 是 |
| borderRadius | 徽章周围边框的半径 | number | 否 | iOS/Android | 是 |
| borderWidth | 徽章周围边框的宽度 | number | 否 | iOS/Android | 是 |
| containerStyle | 顶部容器的额外样式 | ViewStyle | 否 | iOS/Android | 是 |
| customElement | 渲染而不是图标的自定义元素 | JSX.Element | 否 | iOS/Android | 是 |
| hitSlop | 定义触摸事件可以从徽章开始多远 | ViewProps['hitSlop'] | 否 | iOS/Android | 是 |
| icon | 渲染图标徽章 | ImageSourcePropType | 否 | iOS/Android | 是 |
| iconProps | 传递给图标的额外属性 | ImageProps | 否 | iOS/Android | 是 |
| iconStyle | 徽章图标的额外样式 | ImageStyle | 否 | iOS/Android | 是 |
| label | 传递标签(undefined)将呈现斑点徽章。徽章内显示的文本 | string | 否 | iOS/Android | 是 |
| labelFormatterLimit | 超过该数字长度的最大数字,将在末尾显示 '+'。如果设置为不包含在 LABEL_FORMATTER_VALUES 中的值,则不会进行格式化。示例:labelLengthFormatter={2}, label={124}, 标签将显示 '99+' 接收从 1 到 4 的数字,代表标签的最大数字长度 | LabelFormatterValues | 否 | iOS/Android | 是 |
| labelStyle | 徽章标签的额外样式 | TextStyle | 否 | iOS/Android | 是 |
| onPress | 当徽章被按下时调用 | (props: any) => void | 否 | iOS/Android | 是 |
| size | 徽章的大小 | number | 否 | iOS/Android | 是 |
ConnectionStatusBar:顶部栏显示无网络连接状态,该组件依赖 @react-native-community/netinfo 库。
| 名称 | 描述 | 类型 | 必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| allowDismiss | 是否允许用户关闭 | boolean | 否 | iOS/Android | 是 |
| label | 显示为状态的文本 | string | 否 | iOS/Android | 是 |
| onConnectionChange | 处理连接更改事件传播的处理程序 | (isConnected: boolean, isInitial: boolean) => void | 否 | iOS/Android | 是 |
| useAbsolutePosition | 为组件使用绝对位置 | boolean | 否 | iOS/Android | 是 |
ProgressBar:进度条组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| customElement | 在动画进度顶部渲染的自定义元素 | JSX.Element | no | iOS/Android | yes |
| fullWidth | 全宽UI预设 | boolean | no | iOS/Android | yes |
| progress | 进度条进度,取值范围为0到100 | number | no | iOS/Android | yes |
| progressColor | 进度条颜色 | string | no | iOS/Android | yes |
| style | 覆盖容器样式 | ViewStyle | no | iOS/Android | yes |
SkeletonView:骨架屏组件,用于在内容尚未加载完成时展示临时占位效果。使用该组件前需安装 react-native-shimmer-placeholder 和 react-native-linear-gradient 库。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| borderRadius | 骨架屏的边框圆角半径 | number | no | iOS/Android | yes |
| circle | 骨架屏是否为圆形(设置后将覆盖 borderRadius) | boolean | no | iOS/Android | yes |
| colors | 骨架屏的颜色数组,数组长度必须大于或等于2 | string[] | no | iOS/Android | yes |
| customValue | 任意类型的自定义值,将传递给 SkeletonView 并在 renderContent 回调中接收 | any | no | iOS/Android | yes |
| height | 骨架屏的高度 | number | no | iOS/Android | yes |
| listProps | 当 template 设为 SkeletonView.templates.LIST_ITEM 时可用的属性 | SkeletonListProps | no | iOS/Android | yes |
| renderContent | 当内容准备就绪(即 showContent 为 true)时用于渲染内容的函数。该函数会接收 Skeleton 的 customValue 作为参数(即 renderContent(props?.customValue)) | (customValue?: any) => React.ReactNode | no | iOS/Android | yes |
| shimmerStyle | 骨架屏的附加样式 | ViewStyle | no | iOS/Android | yes |
| showContent | 内容已加载完成,开始淡出骨架屏并淡入内容 | boolean | no | iOS/Android | yes |
| style | 覆盖容器样式 | ViewStyle | no | iOS/Android | yes |
| template | 骨架屏的模板类型,可通过 SkeletonView.templates.xxx 访问 | listItem | content | no | iOS/Android | yes |
| testID | 组件测试标识 | string | no | iOS/Android | yes |
| times | 生成重复的骨架屏实例数量 | number | no | iOS/Android | yes |
| timesKey | 重复骨架屏实例的键前缀 | string | no | iOS/Android | yes |
| width | 骨架屏的宽度 | number | no | iOS/Android | yes |
searchInput:用于过滤操作的搜索输入组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| onDismiss | 关闭操作的回调函数 | () => void | no | iOS/Android | yes |
| onClear | 点击清除按钮时的回调函数 | () => void | no | iOS/Android | yes |
| showLoader | 是否显示加载指示器以替代左侧的搜索图标 | boolean | no | iOS/Android | yes |
| customLoader | 自定义加载元素,用于替代默认加载指示器 | React.ReactElement | no | iOS/Android | yes |
| customRightElement | 自定义右侧元素 | React.ReactElement | no | iOS/Android | yes |
| cancelButtonProps | 取消按钮的属性配置 | ButtonProps | no | iOS/Android | yes |
| inaccessible | 关闭此视图及其嵌套子视图的无障碍功能 | boolean | no | iOS/Android | yes |
| useSafeArea | 当 SearchInput 渲染在屏幕顶部安全区域时启用 | boolean | no | iOS/Android | yes |
| containerStyle | 覆盖输入框的样式 | ViewStyle | no | iOS/Android | yes |
| style | 覆盖容器的样式 | ViewStyle | no | iOS/Android | yes |
PieChart:饼状统计图组件。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| segments | 饼图数据段数组 | PieChartSegmentProps[] | no | iOS/Android | yes |
| diameter | 饼图的直径 | number | no | iOS/Android | yes |
| dividerWidth | 各数据段之间分隔线的宽度 | number | no | iOS/Android | yes |
| dividerColor | 各数据段之间分隔线的颜色 | ColorValue | no | iOS/Android | yes |
Incubator.Gradient:渐变组件。
BorderGradient:
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| colors | 渐变颜色数组 | (string | number)[] |
yes | iOS/Android | yes |
| width | 容器宽度 | number | no | iOS/Android | yes |
| height | 容器高度 | number | no | iOS/Android | yes |
| angle | 渐变角度 | number | no | iOS/Android | yes |
| children | 子元素 | React.ReactNode | no | iOS/Android | yes |
| borderWidth | 边框宽度 | number | no | iOS/Android | yes |
| borderRadius | 边框圆角半径 | number | no | iOS/Android | yes |
RectangleGradient:
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| colors | 渐变颜色数组 | (string | number)[] |
yes | iOS/Android | yes |
| width | 容器宽度 | number | no | iOS/Android | yes |
| height | 容器高度 | number | no | iOS/Android | yes |
| angle | 渐变角度 | number | no | iOS/Android | yes |
| children | 子元素 | React.ReactNode | no | iOS/Android | yes |
CircleGradient:
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| colors | 渐变颜色数组 | (string | number)[] |
yes | iOS/Android | yes |
| radius | 容器半径 | number | yes | iOS/Android | yes |
| angle | 渐变角度 | number | no | iOS/Android | yes |
| children | 子元素 | React.ReactNode | no | iOS/Android | yes |
BorderRadiuses:边框圆角。
| Name | Description | Type | Required | Platform | OpenHarmony Support |
|---|---|---|---|---|---|
| br70 | 边框圆角,值为24 | number | no | iOS/Android | yes |
| br90 | 边框圆角,值为36 | number | no | iOS/Android | yes |
API
Color:支持全局样式预设,可通过 Color 获取预设样式。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| loadColors | 加载一组供应用程序使用的颜色。 | ({[key: string]: string}) => void | 否 | iOS/Android | 支持 |
| loadSchemes | 加载一组方案颜色,以支持深色/浅色模式。 | ({[name: string]: {[key: string]: any}}) => void | 否 | iOS/Android | 支持 |
| rgba | 返回带有颜色和透明度的 rgba 字符串 | (color: string, num: number) => string | 否 | iOS/Android | 支持 |
| getColorTint | 获取颜色色调 | (color: string, num: number) => string | 否 | iOS/Android | 支持 |
| isDark | 如果颜色被判定为深色则返回 true(亮色则返回 false) |
(color: string) => boolean | 否 | iOS/Android | 支持 |
ThemeManager:通过 ThemeManager 为您的应用设置全局默认行为。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| setComponentTheme | 通过传递对象或回调为组件设置默认属性 | (componentName, defaultPropsObject) => void | (componentName, componentProps => newDefaultPropsObject) => void | 否 | iOS/Android | 支持 |
Typography:设置样式属性,可通过“属性”的方式直接为组件指定样式。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| loadTypographies | 设置样式属性变量 | ({[name: string]: {[key: string]: any}}) => void | 否 | iOS/Android | 支持 |
Spacings:设置空间大小变量,可通过“属性-变量名”的方式指定样式。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| loadSpacings | 设置空间大小变量 | ({ [key: string]: number }) => void | 否 | iOS/Android | 支持 |
hook:钩子函数。
| 名称 | 描述 | 类型 | 是否必填 | 平台 | OpenHarmony 支持 |
|---|---|---|---|---|---|
| useKeyboardHeight | 获取键盘当前高度 | (): number | 否 | iOS/Android | 支持 |
遗留问题
- KeyboardTrackingView组件,将输入框子节点保持在键盘上方后点击事件位置异常: issue#4
- 原生组件KeyboardAccessoryView切换自定义键盘未实现: issue#3
- Marquee、NumberInput、MaskedInput、TextField和Wizard组件在82上不支持: issue#21
其他
无
目录结构
/rntpc_react-native-ui-lib # 项目根目录
├── harmony # 鸿蒙适配代码
│ └─ ui_lib.har # har包
│ └─ ui_lib # 鸿蒙适配核心代码
│ └─ index.ets # 鸿蒙适配代码入口
│ └─ src/main/ets
│ └─ HightlighterView # 高亮视图
├── src # RN代码
│ └─ index.tsx # 入口文件
│ └─ components # 组件目录
│ └─ styles # 样式目录
│ └─ hooks # 钩子目录
│ └─ utils # 工具目录
├── README_en.md # 英文安装使用方法
├── README.md # 中文安装使用方法
贡献代码
使用过程中发现任何问题都可以提交 Issue,当然,也非常欢迎提交 PR 。
开源协议
本项目基于 The MIT License (MIT) ,请自由地享受和参与开源。
项目介绍
是一套功能全面的 React Native UI 组件库,核心目标是为跨平台应用提供一致、美观且高度可定制的 UI 组件体系,覆盖从基础控件到复杂交互组件的全场景需求,简化 UI 开发流程并保证跨平台体验统一
定制我的领域