1.0.3 • Published 2 years ago

@maiid7/react-custom-input v1.0.3

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

React Custom Input

A simple Input/Select type component to be used in any React project.

Description

React custom input is a simple input with very few dependencies to be used in your project. It can be used as an input and a select to create your forms. It also comes with a default style that can be overridden and all the features you need to handle values.

Getting Started

Install

  • Add this package to your React project using npm

    npm install @/maiid7/react-custom-input

Import

  • Import the custom input in your React project like so :

    import { Input } from 'react-custom-input'

Usage

  • Once imported, use it this way :

    • As an input
    <div>
      <Input 
        label="First Name"
        placeholder="First Name"
        value={form.firstName}
        onChange={handleInputChange}
        regExp={simpleTextRegExp} 
      />
    </div>
    • As a select
    <div>
      <Input
        select
        options={states}
        label="State"
        placeholder="State"
        value={form.state}
        onChange={handleValueChange}
      />
    </div>
  • Available Props :

    NameTypeDescription
    namestringDefine input name
    labelstringIf undefined, label is not displayed
    placeholderstringPlaceholder for input
    styleAdd custom style to input
    classNameAdd custom class to input
    refCan be used to get reference element (instead of using onChange event)
    selectbooleanSet the input type to select
    optionsarrayIf select is true, add select options to input
    valuevariableValue of input
    onChangefunctionRuns when the value of the input changes. The first parameter is the value.

    Check this exemple project for more details on usage.

Authors

Mairo Dronsart
LinkedIn/MairoDronsart

Version History

  • 1.0.3
    • Initial Release

License

CopyRight 2024 Maro Dronsart.

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago