0.3.2 • Published 2 years ago

react-effortless-form v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React-Effortless-Form

Create an effortless, styled form in a few lines!

Live demos in progress, coming soon...

Features include:

  • Easy inputs
  • Create a styled form container
  • Labels, Button and Wrappers
  • More inputs coming soon!

Installation and Usage

The easiest way to install is with npm

npm i react-effortless-form

With React Hooks

import {Form, EmailInput, Wrapper, Label, PasswordInput, SubmitButton} from 'react-effortless-form';
import {useState} from "react";

const App = () => {

    const [email, setEmail] = useState('');
    const [password, setPassword] = useState('');

    return (
        <div
            style={{
                backgroundImage: 'url(https://wallpaperaccess.com/full/6854780.jpg)',
                backgroundSize: '50%',
                width: '100vw',
                height: '100vh',
                display: 'flex',
                justifyContent: 'center',
                alignItems: 'center'
            }}
        >
            <Form
            >
                <Label
                    style={{
                        fontSize: 50,
                        fontWeight: 'bold',
                    }}
                >
                    Login
                </Label>
                <Wrapper>
                    <EmailInput
                        onChange={(val) => setEmail(val)}
                        size={2}
                    />
                    <PasswordInput
                        onChamge={(val) => setPassword(val)}
                        size={2}
                    />
                </Wrapper>
                <SubmitButton
                    style={{width: '300px', textAlign: 'center'}}
                    submitMessage='Log In'
                    onSubmit={() => console.log({email: email, password: password})}
                />
            </Form>
        </div>
    );
}

export default App;

Props

Form

PropTypeDefaultisRequiredDescription
containerColorcolor'white'noGiven a form a container is created with a plain color
containerSizeobject (width: string, height: string)width:'50%' height: '75%'noSets the size for the form container
boxShadowbooltruenoWhether there is a shadow below the container or not

TextInput

PropTypeDefaultisRequiredDescription
textLabelstring-yesSets the label for the input (username, fullname, etc.)
labelColorcolor'white'noSets the color for the label when not selected
textInputColorcolor'white'noSets the color for the input text and the cursor
errorColorcolor'red'noSets the color for when the field is not valid
successColorcolor'green'noSets the color for when the field is valid
onChangefunction-yesThe function to set what happens when the input is changed
regexValidationregex/\w+/noRegex to validate field and change color
inputType'number','text','password''text'noSets the input type for keyboard and how it is shown
minLengthnumber0noMinimum length required for the field for validation
maxLengthnumber255noMaximum length required for the field for validation
size1,2,31noSets the input size

EmailInput

It contains the same props as TextInput except the regexValidation is for email validation and textLabel is now called emailLabel, it is not required and the default value is 'Email'

PasswordInput

It contains the same props as TextInput except the inputType is 'password' and the textLabel is now passwordLabel, it is not required, and the default value is 'Password'

SubmitButton

PropTypeDefaultisRequiredDescription
submitTextstring'Submit'noThe text for the button
submitButtonColorcolor'black'noThe background color of the button
submitButtonTextColorcolor'white'noThe color of the button text
classNamestring'submit-button-class'noSets the classname for styling the button
styleobject{}noStyling the button with inline react styles

Label

PropTypeDefaultisRequiredDescription
submitTextvlauestring''noThe text for the label
classNamestring''noSets the classname for styling the label
styleobject{}noStyling the label with inline react styles

License

MIT Licensed. Copyright (c) 2022 Federico Pochat

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.32

2 years ago

0.2.31

2 years ago

0.2.30

2 years ago

0.2.29

2 years ago

0.2.28

2 years ago

0.2.27

2 years ago

0.2.26

2 years ago

0.2.25

2 years ago

0.2.24

2 years ago

0.2.23

2 years ago

0.2.22

2 years ago

0.2.21

2 years ago

0.2.20

2 years ago

0.2.19

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago