npm package: @paprika/input
Description: The Input component is a standard text input with some enhancements that can be used as a controlled or uncontrolled component.
Author: @paprika
Latest version: 7.0.4

<!-- start: Autogenerated - do not modify -->

# @paprika/input

## Description

The Input component is a standard text input with some enhancements that can be used as a controlled or uncontrolled component.

## Installation

```
yarn add @paprika/input
```

or with npm:

```
npm install @paprika/input
```

## Props

### Input

| Prop           | Type                                                                                                                                                   | required | default                 | Description                                                                                                                                                                                                                              |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| a11yText       | string                                                                                                                                                 | false    | null                    | Provides a non-visible label for this input for assistive technologies.                                                                                                                                                                  |
| children       | node                                                                                                                                                   | false    | null                    | Optional Input.Container to collect props for root DOM element.                                                                                                                                                                          |
| clearIcon      | node                                                                                                                                                   | false    | null                    | Custom icon for the clear action in the input.                                                                                                                                                                                           |
| defaultValue   | string                                                                                                                                                 | false    | null                    | Sets the default input value for an uncontrolled component.                                                                                                                                                                              |
| hasClearButton | bool                                                                                                                                                   | false    | false                   | If true displays a clear button inside the input if it contains a value.                                                                                                                                                                 |
| hasError       | bool                                                                                                                                                   | false    | false                   | If true displays a red border around input to show error.                                                                                                                                                                                |
| icon           | node                                                                                                                                                   | false    | null                    | Displays an icon inside the input.                                                                                                                                                                                                       |
| isDisabled     | bool                                                                                                                                                   | false    | false                   | If true it makes the input disabled.                                                                                                                                                                                                     |
| isReadOnly     | bool                                                                                                                                                   | false    | false                   | If true it makes the input read only.                                                                                                                                                                                                    |
| onChange       | func                                                                                                                                                   | false    | () => {}                | Callback to be executed when the input value is changed. Receives the onChange event as an argument, except when the clear button is clicked, then the argument is null. Required when value prop is provided (component is controlled). |
| size           | [ Input.types.size.SMALL, Input.types.size.MEDIUM, Input.types.size.LARGE]                                                                             | false    | Input.types.size.MEDIUM | Changes the size of the input.                                                                                                                                                                                                           |
| type           | [ Input.types.type.EMAIL, Input.types.type.PASSWORD, Input.types.type.SEARCH, Input.types.type.TELEPHONE, Input.types.type.TEXT, Input.types.type.URL] | false    | Input.types.type.TEXT   | Allows user to specify the type of input.                                                                                                                                                                                                |
| value          | string                                                                                                                                                 | false    | undefined               | The value inside of the input                                                                                                                                                                                                            |
| hasCSSReset    | bool                                                                                                                                                   | false    | false                   | If true `all: unset;` will be applied                                                                                                                                                                                                    |

<!-- end: Autogenerated - do not modify -->
<!-- content -->

### Input.Container

All props and attributes are spread onto the root container `<div>` element.

## Usage

The `<Input>` can be used as a controlled or an uncontrolled component.

To use it as controlled:

```js
import Input from "@paprika/input";
...
const [value, setValue] = React.useState("default value");
...
<Input
  value={value}
  onChange={event => {
    setValue(event ? event.target.value : "");
  }}
/>
```

To use it as an uncontrolled component:

```js
import Input from "@paprika/input";
...
const refInput = React.useRef();
...
<Input
  defaultValue="default value"
  ref={refInput}
/>
...
refInput.current.value // latest value
```

## Dependencies

The `<L10n>` component is a required context provider when the `hasClearButton` prop is provided. It should wrap the `<Input>` (or your application) for localization of the clear button's ARIA label.

<!-- eoContent -->

## Links

- [Storybook Showcase](https://paprika.highbond.com/?path=/story/forms-input--showcase)
- [GitHub source code](https://github.com/acl-services/paprika/tree/master/packages/Input/src)
- [Create GitHub issue](https://github.com/acl-services/paprika/issues/new?label=[]&title=@paprika/input%20[help]:%20your%20short%20description&body=%0A%23%20Help%20wanted%0A%0A%23%23%20Please%20write%20your%20question.%0A*A%20clear%20and%20concise%20description%20of%20what%20the%20question%20is*%0A%0A%23%23%20Additional%20context%0A*Add%20any%20other%20context%20or%20screenshots%20about%20your%20question%20here.*%0A)
- [CHANGELOG](https://github.com/acl-services/paprika/tree/master/packages/Input/CHANGELOG.md)