Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/axisj/react-multi-email

:octocat: A simple react component to format multiple email as the user types.
https://github.com/axisj/react-multi-email

express multi-email react

Last synced: about 2 months ago
JSON representation

:octocat: A simple react component to format multiple email as the user types.

Lists

README

        

[![npm version](https://badge.fury.io/js/react-multi-email.svg)](https://badge.fury.io/js/react-multi-email)
[![](https://img.shields.io/npm/dm/react-multi-email.svg)](https://www.npmjs.com/package/react-multi-email)
[![](https://github.com/axisj/react-multi-email/actions/workflows/npm-test.yml/badge.svg)](https://github.com/axisj/react-multi-email/actions/workflows)

# react-multi-email

A simple react component to format multiple email as the user types.

- Simple code
- No dependency
- Small size
- Simple customization

[See Demo](https://codesandbox.io/s/jpvjk8m5o9)

## Installation

```shell-script
npm install react-multi-email
```

## Usage

```typescript jsx
import * as React from 'react';
import { ReactMultiEmail, isEmail } from 'react-multi-email';
import 'react-multi-email/dist/style.css';

interface Props {}

function BasicExample(props: Props) {
const [emails, setEmails] = React.useState([]);
const [focused, setFocused] = React.useState(false);

return (

Email


{
setEmails(_emails);
}}
autoFocus={true}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
getLabel={(email, index, removeEmail) => {
return (

{email}

removeEmail(index)}>
×


);
}}
/>


react-multi-email value


Focused: {focused ? 'true' : 'false'}


{emails.join(', ') || 'empty'}



);
}

export default BasicExample;
```

## Props


Property
Type
Default
Description


id
string




emails
string[]




onChange
(emails: string[]) => void;




enable
({ emailCnt }: { emailCnt: number }) => boolean;




onDisabled
() => void;




onChangeInput
(value: string) => void;





onFocus
() => void;





onBlur
() => void;





onKeyDown
(evt: React.KeyboardEvent) => void;





onKeyUp
(evt: React.KeyboardEvent) => void;





noClass
boolean





validateEmail
(email: string) => boolean | Promise;





enableSpinner
boolean





style
React.CSSProperties




getLabel

(
email: string,
index: number,
removeEmail: (index: number, isDisabled?: boolean) => void,
) => React.ReactNode;






className
string
''




inputClassName
string
''




placeholder
string | React.ReactNode;





autoFocus
boolean;





spinner
() => React.ReactNode;





delimiter
string;
'[ ,;]'




autoComplete
string | undefined




initialInputValue
string | undefined
''




disableOnBlurValidation
boolean | undefined
false

## License

[MIT](https://opensource.org/licenses/MIT)

> If you don't mind, don't forget to press "star" before leaving.