# simple-contact

> An simple contact form for React

Latest version **0.0.1** (published 2020-04-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-contact
pnpm add simple-contact
yarn add simple-contact
bun add simple-contact
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2020-04-13 |
| First published | 2020-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 38.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | leaveswoods |
| Maintainers | leaveswoods |
| Keywords | react, react-component, contact, form, ui, frontend |

## Links

- npm: https://www.npmjs.com/package/simple-contact
- Repository: https://github.com/leaveswoods/simple-contact-form
- Homepage: https://github.com/leaveswoods/simple-contact-form#readme
- Issues: https://github.com/leaveswoods/simple-contact-form/issues
- npm.io page: https://npm.io/package/simple-contact

## Dependencies (2)

- [validator](https://npm.io/package/validator.md) ^13.0.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2020-04-13

## README

# simple-contact-form

> Simple Contact Form Component for React Applications

## Install
The component is developed in React version 16.9.0, however, 16.8.x seems working as well.

`React >= 16.9.0`

```bash
npm install --save simple-contact
```

## Usage
Simple Contact Form is built for simple while also providing some customizability. Here is a basic usage:
```jsx
import React, { useState } from 'react';

import ContactForm from 'simple-contact';
// Don't forget to import styles
import 'simple-contact/dist/index.css';

function Example(props) {
const [loading, setLoading] = useState(false);
  const [alertMessageProps, setAlertMessageProps] = useState({
    message: "",
    type: "",
  });

  const mockAsync = () => {
    setLoading(true);
    return new Promise((resolve) => {
      setTimeout(() => {
        setAlertMessageProps({
          message: "You message has been sent",
          type: "success",
        });
        setLoading(false);
        resolve(true);
      }, 1000);
    });
  };

  return (
    <ContactForm
      fields={[
        { type: "nameGroup", required: true },
        { type: "phone", required: true },
        { type: "email", required: true },
        { type: "message", required: true },
      ]}
      loading={loading}
      submitButtonProps={{
        text: "Submit",
      }}
      alertMessageProps={alertMessageProps}
      onSubmit={mockAsync}
    />
  );
}
```

## Form Props.
|Property|Type|Required|default|Description|
|-------|-----|----|----------|--------------------|
|onSubmit|function|Yes||set the handler to handle click submit
|loading|Boolean|No|false|set the loader visble state of submit button
alertMessageProps|Object|No|`{text: "", type: ""}`|Alert message props, you can set alert message by passing `{text: "A alert message, ...}`, or set alert type by passing `{..., type: "success"}` to this prop, available types are `success` and `error` 
|submitButtonProps|Object|No|`{text: "Submit", style: {}}`|Submit button props, example, `{ text: "Submit", style:{ color: "white", backgroundColor: "blue"  }}` 
|fields|obj[ ] or str[ ]|No|`fields`|set the fiels to be used in form, currently available, fields are `nameGroup`(first name and last name), `email`, `phone`, `message`, usage could be found in Codesandbox demo
|title|string|No||set title of form


## License
Simple React Form is licensed under the MIT license. (https://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/simple-contact · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
