New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-input

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-input

Easy forms for React.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
160
decreased by-1.84%
Maintainers
1
Weekly downloads
 
Created
Source

react-input npm version Dependency Status

Overview

React input is a lightweight, dependency free component for building forms in React without having to think about what happens under the hood.

Right now, only textarea, password, email and text inputs can be used, but it can be expanded to provide date pickers, checkboxes/switches, selection menus, and file inputs in the future.

Usage

  • Install the component via npm: npm install react-input
  • Require the form component
<form onSubmit={this.myFormSubmissionHandler}>
  <Field ref="email" name="email">
    <Label />
    <Input
      required
      type="email"
      placeholder="Name"
    />
  </Field>
  <Submit />
</form>

For a detailed example, see the example project.

Props

All standard HTML input attributes are supported and can be used as props.

Input Methods

MethodUsage
focusInput.focus()Sets the focus on the element.
valueInput.value()Returns the value on the element.*
clearInput.clear()Clears the value on the element.

*Note that you can also change the value of an input directly by `Input.value = 'newValue'

Input Events

EventDescription
onChangeRuns on change. Includes the name and value of the input.

Considering this component:

<Field ref="email" name="email">
  <Input
    type="email"
    onChange={::this.handleInputChange}
  />
</Field>

An event handler might look like:

handleInputChange(value, field, event) {
  return this.setState({
    [field]: value
  });
}

DOM Tree

As this component does not include CSS styles to use, you will need to add your own styles. If you are using inline styles, just include the style prop on each component.

The default DOM tree of the component is included below for reference. You can also override the default classes by just using className like you would normally.

<div class="input-group">
  <label class="input-group-label"></label>
  <input class="input-group-input">
</div>

Built with care in New Orleans by Patrick Burtchaell.

Copyright 2015 Patrick Burtchaell. Licensed MIT.

Keywords

FAQs

Package last updated on 26 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc