tz-react-simple-select
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

React Simple Select

A React component who provides a select input handling the state value.

Installation

Install tz-react-simple-select with npm

  npm install tz-react-simple-select

or with Yarn

yarn add tz-react-simple-select

Usage/Examples

import { FC, useState } from 'react'
import { Select } from 'tz-react-simple-select'

const App: FC<{}> = () => {
  const [favoriteIceCreamFlavour, setFavoriteIceCreamFlavour] = useState<string>('')

  const favoriteIceCreamFlavourOpts = [
    {
      label: 'Chocolate',
      value: 'chocolate',
    },
    {
      label: 'Vanilla',
      value: 'vanilla',
    },
    {
      label: 'Cookie',
      value: 'cookie',
    },
    {
      label: 'Mint',
      value: 'Mint',
    },
  ]

  const onChange = (e: ChangeEvent<HTMLInputElement>) => {
    setFavoriteIceCreamFlavour(e.target.value)
  }

  return (
    <div>
      <Select
        label="What's your favorite ice cream flavour ?"
        options={favoriteIceCreamFlavourOpts}
        value={favoriteIceCreamFlavour}
        onChange={setFavoriteIceCreamFlavour}
        id='favoriteFlavour'
      />
    </div>
  )
}

export default App

Feedback

If you have any feedback, please reach out to us at tom.zidani@gmail.com

License

MIT

Package Sidebar

Install

npm i tz-react-simple-select

Weekly Downloads

7

Version

1.0.8

License

MIT

Unpacked Size

10.2 kB

Total Files

17

Last publish

Collaborators

  • tomzidani