npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tuya-oh/react-native-smooth-pincode-input

v1.0.9-rc-0.0.2

Published

A cross-platform, smooth, lightweight, customizable PIN code input component for React Native.

Readme

[!TIP] Github 地址

安装与使用

进入到工程目录并输入以下命令:

npm

npm install @tuya-oh/react-native-smooth-pincode-input

yarn

yarn add @tuya-oh/react-native-smooth-pincode-input

下面的代码展示了这个库的基本使用场景:

[!WARNING] 使用时 import 的库名不变。

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import SmoothPinCodeInput from 'react-native-smooth-pincode-input';

export default class App extends React.Component {

  state = {
    code: '',
    password: '',
  };
  pinInput = React.createRef();

  _checkCode = (code) => {
    if (code != '1234') {
      this.pinInput.current.shake()
        .then(() => this.setState({ code: '' }));
    }
  }

  render() {
    const { code, password } = this.state;
    return (
      <View style={styles.container}>
        {/* default */}
        <View style={styles.section}>
          <Text style={styles.title}>Default</Text>
          <SmoothPinCodeInput
            ref={this.pinInput}
            value={code}
            onTextChange={code => this.setState({ code })}
            onFulfill={this._checkCode}
            onBackspace={() => console.log('No more back.')}
            />
        </View>

        {/* password */}
        <View style={styles.section}>
          <Text style={styles.title}>Password</Text>
          <SmoothPinCodeInput password mask="﹡"
            cellSize={36}
            codeLength={8}
            value={password}
            onTextChange={password => this.setState({ password })}/>
        </View>

        {/* underline */}
        <View style={styles.section}>
          <Text style={styles.title}>Underline</Text>
          <SmoothPinCodeInput
            cellStyle={{
              borderBottomWidth: 2,
              borderColor: 'gray',
            }}
            cellStyleFocused={{
              borderColor: 'black',
            }}
            value={code}
            onTextChange={code => this.setState({ code })}
            />
        </View>

        {/* customized */}
        <View style={styles.section}>
          <Text style={styles.title}>Customized</Text>
          <SmoothPinCodeInput
            placeholder="⭑"
            cellStyle={{
              borderWidth: 2,
              borderRadius: 24,
              borderColor: 'orange',
              backgroundColor: 'gold',
            }}
            cellStyleFocused={{
              borderColor: 'darkorange',
              backgroundColor: 'orange',
            }}
            textStyle={{
              fontSize: 24,
              color: 'salmon'
            }}
            textStyleFocused={{
              color: 'crimson'
            }}
            value={code}
            onTextChange={code => this.setState({ code })}
            />
        </View>

        {/* Custom placeholder & mask */}
        <View style={styles.section}>
          <Text style={styles.title}>Custom Placeholder</Text>
          <SmoothPinCodeInput
            placeholder={<View style={{
              width: 10,
              height: 10,
              borderRadius: 25,
              opacity: 0.3,
              backgroundColor: 'blue',
            }}></View>}
            mask={<View style={{
              width: 10,
              height: 10,
              borderRadius: 25,
              backgroundColor: 'blue',
            }}></View>}
            maskDelay={1000}
            password={true}
            cellStyle={null}
            cellStyleFocused={null}
            value={code}
            onTextChange={code => this.setState({ code })}
          />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  section: {
    alignItems: 'center',
    margin: 16,
  },
  title: {
    fontSize: 16,
    fontWeight: 'bold',
    marginBottom: 8,
  },
});

约束与限制

属性

[!TIP] "Platform"列表示该属性在原三方库上支持的平台。

[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。

| Name | Description | Type | Required | Platform | HarmonyOS Support | 默认值 | | ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | ----------- | ----------------- | ---------------------------------------- | | value | 输入框显示的值 | String | no | IOS/Android | yes | '' | | codeLength | 输入字符的个数 | Number | no | IOS/Android | yes | 4 | | cellSize | 每个单元格的大小 | Number | no | IOS/Android | yes | 48 | | cellSpacing | 单元格之间的间距 | Number | no | IOS/Android | yes | 4 | | placeholder | '' | String | no | IOS/Android | yes | Element | | mask | '*' | String | no | IOS/Android | yes | Element | | maskDelay | 字符被遮罩前的延迟,单位为毫秒 | Number | no | IOS/Android | yes | 200 | | password | 是否遮罩输入值。每个单元格使用 mask 属性进行遮罩 | Boolean | no | IOS/Android | yes | FALSE | | autoFocus | 如果为 true,则在组件挂载时聚焦输入框 | Boolean | no | IOS/Android | yes | FALSE | | editable | 如果为 false,则每个单元格不可编辑 | Boolean | no | IOS/Android | yes | TRUE | | animated | 是否启用动画 | Boolean | no | IOS/Android | yes | TRUE | | animationFocused | 聚焦单元格的动画。可以是预设动画的字符串形式,也可以是自定义动画对象 | String, Object | no | IOS/Android | yes | 'pulse' | | restrictToNumbers | 是否仅限制输入数字 | Boolean | no | IOS/Android | yes | FALSE | | containerStyle | 整个单元格容器的视图样式 | React View StyleSheet | no | IOS/Android | yes | {} | | cellStyle | 每个单元格的视图样式 | React View StyleSheet | no | IOS/Android | yes | { borderColor: 'gray', borderWidth: 1} | | cellStyleFocused | 聚焦单元格的视图样式 | React View StyleSheet | no | IOS/Android | yes | { borderColor: 'black', borderWidth: 2 } | | textStyle | 单元格值的文本样式 | React Text StyleSheet | no | IOS/Android | yes | { color: 'gray', fontSize: 24 } | | textStyleFocused | 聚焦单元格值的文本样式 | React Text StyleSheet | no | IOS/Android | yes | { color: 'black' } | | onFulfill | 当输入完全填满时调用的回调函数 | Function | no | IOS/Android | yes | null | | onTextChange | 当文本更改时调用的回调函数 | Function | no | IOS/Android | yes | null | | onBackspace | 当输入为空且按下退格键时调用的回调函数 | Function | no | IOS/Android | yes | null | | keyboardType | 确定打开的键盘类型 | Enum('default', 'number-pad', 'decimal-pad', 'numeric', 'email-address', 'phone-pad') | no | IOS/Android | yes | 'numeric' |

开源协议

本项目基于 MIT License (MIT) ,请自由地享受和参与开源。