Skip to content

Commit 1f07f08

Browse files
committed
chore: updated readme with passcode
1 parent 961b13b commit 1f07f08

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
![headless-otp-header-image](media/react-headless-passcode.001.jpeg)
1+
![headless-passcode-header-image](media/react-headless-passcode.001.jpeg)
22

3-
# react-headless-otp
3+
# react-headless-passcode
44

5-
A headless UI for building easy to use OTP component.
5+
A headless UI for building easy to use passcode component.
66

7-
*What is an OTP component?*
7+
*What is an passcode component?*
88
It is a group of input elements with each element only accepting one character. This component is generally used in authentication flows.
99

1010
* [Installation](#installation)
@@ -16,23 +16,23 @@ It is a group of input elements with each element only accepting one character.
1616
## Installation
1717

1818
```shell
19-
yarn add react-headless-otp
19+
yarn add react-headless-passcode
2020
```
2121

2222

2323
## Usage
2424

2525
```tsx
26-
import { useOtp } from "react-headless-otp";
26+
import { usePasscode } from "react-headless-passcode";
2727
```
2828

29-
With the `useOtp` hook you just need to pass the `arrayValue` default property and in return you get the `array` in which the actual otp value is stored, various event hanlders that handles the focus management between multiple inputs and `refs` that references each input element.
29+
With the `usePasscode` hook you just need to pass the `arrayValue` default property and in return you get the `array` in which the actual passcode value is stored, various event hanlders that handles the focus management between multiple inputs and `refs` that references each input element.
3030

3131
For example:
3232

3333
```tsx
34-
const OTPComponent = () => {
35-
const { array, getEventHandlers, refs } = useOtp({
34+
const PasscodeComponent = () => {
35+
const { array, getEventHandlers, refs } = usePasscode({
3636
arrayValue: [0, 0, 0, 0, 0, 0],
3737
});
3838

@@ -62,21 +62,21 @@ const OTPComponent = () => {
6262
```
6363

6464
>**NOTE:**
65-
> It is important to initialize the `refs` object with the current input element because this is how the `useOtp` is able to track the current index and manage the focused state across multiple inputs. Make sure to assign this element to the `refs` or else the focus won't change!!
65+
> It is important to initialize the `refs` object with the current input element because this is how the `usepasscode` is able to track the current index and manage the focused state across multiple inputs. Make sure to assign this element to the `refs` or else the focus won't change!!
6666
```tsx
6767
ref={(el) => el && (refs.current[index] = el)}
6868
```
6969

7070
## Features
7171
- Allow entering alpha numeric characters
7272
- Expose a flag: `isComplete` that tells whether all the input boxes are filled or not
73-
- Expose a state variable: `currentFocusedIndex`. It tells us the currently focused index of the OTP component.
73+
- Expose a state variable: `currentFocusedIndex`. It tells us the currently focused index of the passcode component.
7474
- Exposes event handlers that can be seamlessly used with the input element.
75-
- OTP value can be pasted partially, fully, from start, or from middle.
75+
- Passcode value can be pasted partially, fully, from start, or from middle.
7676

7777
## API
7878

79-
The `useOtp` hook accepts following props
79+
The `usePasscode` hook accepts following props
8080
| Prop Name | Type | Description |
8181
|---------------- |------------------------ |----------------------------------------------------------------------- |
8282
| arrayValue | `(number \| string)[]` | Default array value that helps to determine the size of the component |

0 commit comments

Comments
 (0)