New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

input-chips

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

input-chips

prettiest input with chips

latest
Source
npmnpm
Version
0.1.10
Version published
Maintainers
1
Created
Source

input-chips

Contributions of any kind welcome!

Motivation

This project provides a input with chips. It is inspired by material-ui-chip-input

But this package is deprecated, and I wanted a different design.

I thought the form with chips inside the input was inappropriate and it was strange that the position of the placeholder kept changing.

Installation

npm i input-chips

Point Of Focus

  • Pretty UI

  • Easy use

  • Eliminate the bug from material-ui-chip-input where Korean is entered twice

  • Improving developer experience through tsdoc and storybook

npm address

Usage

import { InputChips } from "input-chips";
import React, { useReducer } from 'react';

const reducer = (state, action) => {
  switch (action.type) {
    case "ADD":
      return state.includes(action.keyword)
        ? state
        : [...state, action.keyword];
    case "DELETE":
      return state.filter((existing) => existing !== action.keyword);
    default:
      return state;
  }
};

const App = () => {
  const [keywords, dispatch] = useReducer(reducer, []);

  const handleAdd = (keyword: string) => {
    dispatch({ type: "ADD", keyword: keyword });
  };

  const handleDelete = (keyword: string) => {
    dispatch({ type: "DELETE", keyword: keyword });
  };

  return (
    <InputChips
      id={id}
      title={title}
      tip={tip}
      placeholder={inputChips.placeholder}
      keywords={keywords}
      onDelete={handleDelete}
      onAdd={handleAdd}
    />
  );
};

export default App;

Result

If you want to try the component yourself instead of watching a gif, head over to the storybook for a live demo !

Properties

NameTypeDefaultDescription
idstringString key for input-label coupling
titlestringEnter your input label
tipstringEnter tip for using input. It's located next to title.
placeholderstringEnter the placeholder showed by input
keywordsstring[]It will return pretty chips
onAddfunction(arg0: string)This will send you a keyword, so you should manage it using hook like useState.
onDeletefunction(arg0: string)This will send you a keyword, so you should manage it using hook like useState.
disabledbooleanTrue if you want to make disable input
maxLengthnumberIt defines the maximum number of characters
minLengthnumberIt defines the minimum number of characters
namestringA string specifying a name for the input control.
readonlybooleanA Boolean attribute which, if present, indicates that the user should not be able to edit the value of the input.
requiredbooleanRequired is a Boolean attribute which, if present, indicates that the user must specify a value for the input before the owning form can be submitted.
borderstringYou can customize your input border.
backgroundstringYou can customize your input background and chip background.

Keywords

input

FAQs

Package last updated on 29 Dec 2022

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