1.1.0 • Published 2 years ago

react-pills-component v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-pills-component

react-pills-component lets you create a pill or capsule from a provided list.You select/deselect pills and use props to style your pills.

react-pills-component

Installation

npm install --save react-pills-component

Usage

import Pills from "react-pills-component";

   const data = [
       {
        text: "Apple",
        id: "1",
        pillColor: "yellow",
        selected: false,
        selectedPillColor: "blue",
        textColor: "white",
      },
      {
        text: "Milk",
        id: "2",
        pillColor: "blue",
        selected: false,
        selectedPillColor: "yellow",
        textColor: "white",
      },
      {
        text: "Sunday",
        id: "3",
        pillColor: "orange",
        selected: false,
        selectedPillColor: "white",
        textColor: "grey",
      },
      {
        text: "The brightest star",
        id: "4",
        pillColor: "white",
        selected: false,
        selectedPillColor: "blue",
      },
      {
        text: "Javascript",
        id: "5",
        pillColor: "red",
        selected: false,
        selectedPillColor: "blue",
        textColor: "white",
      }
    ],

   <Pills itemList={data} selectedPill={this.selectedData} />

Inputs to pass and Props

Input/PropsNameMandatoryTypeDescription
InputitemListyesarrayArray of objects which will contain information about pill text and styles to be be applied.
InputitemList.textyesstringText to be displayed inside the pill.
InputitemList.idyesstringA unique string which will be associated with the pill.
InputitemList.selectedyesbooleanBoolean value used to identify if a pill is selected or not.
InputitemList.pillColornostringBackground color for the pill.Default color is azure.
InputitemList.selectedPillColornostringBackground color for the pill when a pill is selected(itemList.selected = true).Default color is violet.
InputitemList.textColornostringText color for the pill.Default color is black.
PropsselectedPillyesfunctionFunction that will give back the selected value.

License

MIT