Gathering detailed insights and metrics for react-multivalue-text-input-field
Gathering detailed insights and metrics for react-multivalue-text-input-field
npm install react-multivalue-text-input-field
Typescript
Module System
Node Version
NPM Version
67.2
Supply Chain
98.7
Quality
77.7
Maintenance
100
Vulnerability
100
License
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
260
Last Day
1
Last Week
2
Last Month
17
Last Year
260
Minified
Minified + Gzipped
Latest Version
1.0.2
Package Id
react-multivalue-text-input-field@1.0.2
Unpacked Size
24.27 kB
Size
7.58 kB
File Count
12
NPM Version
10.9.0
Node Version
20.14.0
Published on
Nov 15, 2024
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
100%
2
Compared to previous week
Last Month
-5.6%
17
Compared to previous month
Last Year
0%
260
Compared to previous year
1
26
The MultiInputField
component is a versatile and customizable React input field that enables users to add, clear, or remove multiple values. It’s ideal for tags, categories, keywords, or any multi-value input requirements, with extensive support for custom styling and UI elements.
First, install the package via npm:
1npm install react-multivalue-text-input-field
1import MultiInputField from 'react-multivalue-text-input-field'; 2import React, { useState } from 'react';
Create a state to hold the input values using the useState
hook.
1const App = () => { 2 const [values, setValues] = useState<string[]>([]); 3 4 return ( 5 <MultiInputField 6 values={values} 7 setValues={setValues} 8 label="Enter Tags" 9 placeholder="Type and press enter" 10 required={true} 11 /> 12 ); 13}; 14 15export default App;
In this example, the values
array will hold the current tags, and setValues
updates this array when new tags are added or removed.
The MultiInputField
component accepts the following props, allowing for comprehensive customization:
Prop | Type | Description |
---|---|---|
values | string[] | Array of initial values for the input field. |
setValues | (values: string[]) => void | Function that updates the values array on adding or removing tags. |
Prop | Type | Description |
---|---|---|
label | string | Label text for the input field. |
labelStyle | string | Additional CSS class or style string for the label styling. |
placeholder | string | Placeholder text that appears when no values are entered. |
optionStyle | OptionStyleType | Custom styling for individual list items (background color, padding, etc.). |
optionTextStyle | OptionTextType | Style properties for the text inside each list item. |
optionCloseIcon | React.ReactNode | Custom icon component for removing a value. |
optionCloseIconStyle | string | CSS class or style string for the remove icon styling. |
containerFocusedStyle | string | CSS styling applied to the container when it is focused. |
required | boolean | Marks the input field as required if set to true . |
Here’s an example that demonstrates how to utilize various props for a fully customized experience:
1<MultiInputField 2 values={values} 3 setValues={setValues} 4 label="Tags" 5 labelStyle="custom-label-class" // Custom label CSS class for unique styling 6 placeholder="Type and hit Enter" // Placeholder text when no values are entered 7 optionStyle={{ 8 backgroundColor: '#e0f7fa', 9 paddingHorizontal: '8px', 10 paddingVertical: '4px', 11 borderRadius: '4px' 12 }} // List item styling 13 optionTextStyle={{ 14 color: '#00796b', 15 fontSize: '14px', 16 fontFamily: 'Arial, sans-serif', 17 fontWeight: 'bold' 18 }} // Text styling inside list items 19 optionCloseIcon={<span>✖</span>} // Custom close icon using a 'x' symbol 20 optionCloseIconStyle="custom-close-icon-class" // Custom close icon style 21 containerFocusedStyle="focused-container-class" // Container style on focus 22 required // Sets the field as mandatory 23/>
backgroundColor
, paddingHorizontal
, paddingVertical
, and borderRadius
.color
, fontSize
, fontFamily
, and fontWeight
.1import React, { useState } from 'react'; 2import MultiInputField from 'react-multivalue-text-input-field'; 3 4const TagInput = () => { 5 const [tags, setTags] = useState<string[]>(['Example Tag 1', 'Example Tag 2']); 6 7 return ( 8 <MultiInputField 9 values={tags} 10 setValues={setTags} 11 label="Your Tags" 12 labelStyle="custom-label-style" 13 placeholder="Add a tag and press enter" 14 optionStyle={{ 15 backgroundColor: '#ffeeff', 16 paddingHorizontal: '10px', 17 paddingVertical: '5px', 18 borderRadius: '8px' 19 }} 20 optionTextStyle={{ 21 color: '#aa00aa', 22 fontSize: '13px' 23 }} 24 optionCloseIcon={<span>×</span>} 25 optionCloseIconStyle="close-icon-style" 26 containerFocusedStyle="input-focused-style" 27 required 28 /> 29 ); 30}; 31 32export default TagInput;
For users who want to define their own custom styles, use the following guidelines:
1.custom-label-style { 2 font-size: 16px; 3 color: #333; 4} 5 6.custom-close-icon-class { 7 font-size: 12px; 8 color: #ff3333; 9 cursor: pointer; 10} 11 12.input-focused-style { 13 border: 2px solid #007bff; 14}
This project is licensed under the MIT License. Please see the LICENSE file for more information.
No vulnerabilities found.
No security vulnerabilities found.