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

rn-code-input

v0.0.4

Published

React-Native Code input implementation

Readme

rn-code-input

This package provides a React Native component for creating a secure and customizable code input field. It allows users to enter a series of digits or characters and provides visual feedback as they type.

Features

  • Secure Input: The component displays a mask (e.g., ●) over the entered characters, improving security for one-time passwords (OTPs) or PINs.
  • Customization: You can customize the appearance of individual code boxes using props like activeBoxStyle, inActiveBoxStyle, textStyle, and boxStyle.
  • Flexibility: Set the desired code length with the length prop.
  • Optional Soft Keyboard Focus: Control whether the soft keyboard appears automatically when the component receives focus with the showSoftInputOnFocus prop.

Installation

npm install rn-code-input

or

yarn add rn-code-input

Usage

Import the RNCodeInput component in your React Native project:

import RNCodeInput from "rn-code-input";

Basic Usage:

import React, { useState } from "react";
import { View } from "react-native";

import RNCodeInput from "rn-code-input";

const App = () => {
  const [value, setValue] = useState("");

  const handleChange = (text) => setValue(text);

  return (
    <View>
      <RNCodeInput value={value} length={6} onChange={handleChange} />
    </View>
  );
};

export default App;

Props

RNCodeInput Props:

  • value: (string) - The current entered code.
  • onChange: (function) - Callback function triggered when the code changes.
  • length: (number) - (Optional) The desired number of code boxes (default: 6).
  • hide: (boolean) - (Optional) Whether to display a mask over the entered characters (default: false).
  • showSoftInputOnFocus: (boolean) - (Optional) Whether to show the soft keyboard automatically when the component receives focus (default: false).
  • activeBoxStyle: (ViewStyle) - (Optional) Styles applied to the active code box (e.g., when focused).
  • inActiveBoxStyle: (ViewStyle) - (Optional) Styles applied to inactive code boxes.
  • mask: (string) - (Optional) The character to display as a mask for entered characters (default: ●).
  • textStyle: (TextStyle) - (Optional) Styles applied to the text displayed within the code boxes.
  • boxStyle: (ViewStyle) - (Optional) Styles applied to individual code boxes.
  • style: (ViewStyle) - (Optional) Styles applied to the overall container view.

CodeBox Props: (These props are passed internally and not intended for direct use)

  • value: (string) - The character entered in this specific code box.
  • values: (string) - The entire entered code value.
  • index: (number) - The index of this specific code box within the group.
  • hide: (boolean) - Whether to display a mask in this code box.
  • activeBoxStyle: (ViewStyle) - Styles applied to the active code box.
  • inActiveBoxStyle: (ViewStyle) - Styles applied to the inactive code box.
  • filledBoxStyle: (ViewStyle) - Styles applied to the filled boxes.
  • mask: (string) - The character to display as a mask.
  • textStyle: (TextStyle) - Styles applied to the text displayed within the code box.
  • boxStyle: (ViewStyle) - Styles applied to this specific code box.

Example

This example demonstrates a basic code input with a custom active box style:

import React, { useState } from "react";
import { View } from "react-native";

import RNCodeInput from "rn-code-input";

const App = () => {
  const [value, setValue] = useState("");

  const handleChange = (text) => setValue(text);

  return (
    <View>
      <RNCodeInput
        value={value}
        length={5}
        onChange={handleChange}
        activeBoxStyle={{ borderColor: "red" }}
        inActiveBoxStyle={{ borderColor: "gray" }}
        filledBoxStyle={{ borderColor: "green" }}
        boxStyle={{ borderRadius: 99, marginHorizontal: 5 }}
        hide
      />
    </View>
  );
};

export default App;

Contributing

Feel free to submit pull requests for bug fixes or improvements to this package.