Socket
Socket
Sign inDemoInstall

@paprika/input

Package Overview
Dependencies
102
Maintainers
4
Versions
166
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paprika/input

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


Version published
Maintainers
4
Weekly downloads
4,414
decreased by-28.13%

Weekly downloads

Readme

Source

@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

PropTyperequireddefaultDescription
a11yTextstringfalsenullProvides a non-visible label for this input for assistive technologies.
childrennodefalsenullOptional Input.Container to collect props for root DOM element.
clearIconnodefalsenullCustom icon for the clear action in the input.
defaultValuestringfalsenullSets the default input value for an uncontrolled component.
hasClearButtonboolfalsefalseIf true displays a clear button inside the input if it contains a value.
hasErrorboolfalsefalseIf true displays a red border around input to show error.
iconnodefalsenullDisplays an icon inside the input.
isDisabledboolfalsefalseIf true it makes the input disabled.
isReadOnlyboolfalsefalseIf true it makes the input read only.
onChangefuncfalse() => {}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]falseInput.types.size.MEDIUMChanges 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]falseInput.types.type.TEXTAllows user to specify the type of input.
valuestringfalseundefinedThe value inside of the input
hasCSSResetboolfalsefalseIf true all: unset; will be applied

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:

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:

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.

  • Storybook Showcase
  • GitHub source code
  • Create GitHub issue
  • CHANGELOG

FAQs

Last updated on 06 Jan 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc