0.2.10 • Published 12 months ago

cmation-formsbuilder v0.2.10

Weekly downloads
-
License
-
Repository
github
Last release
12 months ago

Forms Input Controller for CMATION

More information coming soon.\ This project really only works if you use bootstrap 5 on your react app.\ I made this package because I use this on all projects I create.\

If you want a simple way to create forms with React & bootstrap 5, this is the package for you.\

Installation

npm install cmation-formsbuilder

Sizing

I use bootstrap form-control sizing here so adding the attribute

inputSize="lg"

would make the input field large.

inputSize="sm"

would make the input field small.\ Not specifying a size will make the field size medium / normal.

Usage

Text Input Field

import { FormInput } from 'cmation-formsbuilder';

let errors = [];
errors.name = "This field is required";
    
<FormInput 
    type="text"
    name="email"
    label="Email"
    placeholder="Enter your email"
    value={name}
    floatingLabel={true}
    onChange={value => setEmail(value)}
    error={errors.name}
/>
<FormInput 
    type="text"
    name="email"
    label="Email"
    inputSize="lg"
    placeholder="Enter your email"
    value={name}
    onChange={value => setEmail(value)}
    error={errors.name}
/>
<FormInput 
    type="text"
    name="email"
    label="Email"
    placeholder="Enter your email"
    value={name}
    onChange={value => setEmail(value)}
    error={errors.name}
/>
<FormInput 
    type="text"
    name="email"
    label="Email"
    inputSize="sm"
    placeholder="Enter your email"
    value={name}
    onChange={value => setEmail(value)}
    error={errors.name}
/>

Textarea Input Field

<FormInput 
    type="textarea"
    name="message"
    label="Message"
    placeholder="Type your message here"
    value={name}
    onChange={value => setMessage(value)}
    error={errors.name}
/>

Toggle

acts like a boolean filed 1 or 0 / true or false

<FormInput
    type="toggle"
    label="Active"
    name="active"
    value={active}
    hideBorder={true}
    onChange={(value) => setActive(value)}
/>

Example React Component

I am only including the return statement to keep the example short. This is a sample sign in component.

return (
    <div className="card">
        <div className="card-body">
            <div className="m-sm-4">
                <div className="text-center">
                    <h1 className="h2">sign in</h1>
                    <p className="lead">Sign in to the website</p>
                    {errorMessage && (
                        <div
                            className="alert alert-danger alert-dismissible fade show"
                            role="alert"
                        >
                            <div className="alert-message">{errorMessage}</div>
                        </div>
                    )}
                </div>
                <form onSubmit={(e) => e.preventDefault()}>
                    <FormInput
                        type="email"
                        id="username"
                        label="Email"
                        name="username"
                        inputSize="lg"
                        value={username}
                        hideBorder={true}
                        floatingLabel={true}
                        placeholder="Enter your email"
                        autoComplete="username"
                        onChange={(value) => setUsername(value)}
                        error={errors.username}
                    />
                    <FormInput
                        type="password"
                        id="password"
                        label="Password"
                        name="password"
                        inputSize="lg"
                        floatingLabel={true}
                        value={password}
                        hideBorder={true}
                        hideMeter={true}
                        placeholder="Enter your password"
                        autoComplete="current-password"
                        onChange={(value) => setPassword(value)}
                        error={errors.password}
                    />
                    <div className="row">
                        <div className="col-6 text-end mt-3">
                            <button className="btn btn-primary" onClick={onSubmit}>
                                <i className="fas fa-unlock-alt" /> Sign in
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
);

License

MIT

0.2.10

12 months ago

0.2.9

1 year ago

0.2.8

1 year ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.31-n

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.30

2 years ago

0.1.29

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.21

2 years ago

0.1.20

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago