react-duallist-selector

1.0.3 • Public • Published

react-duallist-selector

A basic dual list box for react.

screenshot

Usage

Installation

Install the library:

using nmp:

npm i react-duallist-selector

Render Components

import { useState } from "react";
import DualList from 'react-duallist-selector'

function App() {
  const availableList = [
    "Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6", "Option 7"
  ]

  const [selectedList, setSelectedList] = useState([])

  const option1 = {
    title1: 'Available Fields',
    title2: 'Selected Fields',
    data: availableList,
  }

  useEffect(() => {
    console.log(selectedList)
  }, [selectedList])

  return (
    <>
      <DualList 
        options = {option1}
        selected = {selectedList}
        onSelectChange = {(newArray) => setSelectedList(newArray)}
      />
    </>
  )
}

export default App;

As you add the values to the selected list the selectedList will update automatically.

Package Sidebar

Install

npm i react-duallist-selector

Weekly Downloads

2

Version

1.0.3

License

ISC

Unpacked Size

30.7 kB

Total Files

5

Last publish

Collaborators

  • prabhashbhajani