0.0.7 β€’ Published 1 year ago

react-beautiful-dropdown v0.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

react-beautiful-dropdown

πŸ—οΈ Online Demo

πŸš€ Getting Started

  • Compatibility

    • This package uses @emotion/styled": "^11.10.6 & react-icons: "^4.7.1" as peer dependencies.
  • Installation

    • Install it via npm, by using
        npm install react-beautiful-dropdown
    • or via yarn, by hitting
        yarn add react-beautiful-dropdown
  • Importing

    • Import it in your project, by using
        import ReactDropdown from "react-beautiful-dropdown"
  • Using

    • Use it by adding,
    			<ReactDropdown
    				value={string}
    				options={options}
    				valueHandler={inputHandler}
    				placeholder="Type or select value here. . ."
    				error={{ isError: false, errorText: "Error" }}
    				// customInputStyles={{}}
    				// customDropdownItemStyles={{}}
    			/>

πŸ’» Code Snippet Example

import ReactDropdown from "react-beautiful-dropdown";

const App = () => {
 const [string, setString] = useState("")

  const [options,] = useState([
    { id: '1', label: 'Grinning face πŸ˜€' },
    { id: '2', label: 'Grinning face with big eyes πŸ˜ƒ	' },
    { id: '3', label: 'Beaming face with smiling eyes 😁' },
    { id: '4', label: 'Smiling face with halo πŸ˜‡' },
    { id: '5', label: 'Star-struck 🀩' },
    { id: '6', label: 'Crazy face with tongue out πŸ€ͺ' },
    { id: '7', label: 'Face in clouds πŸ˜Άβ€πŸŒ«οΈ' },
    { id: '8', label: 'Relieved face 😌' },
    { id: '9', label: 'Miling face with sunglasses 😎' },
    { id: '10', label: 'Alien monster πŸ‘Ύ' },
  ])

  const inputHandler = (val: string) => {
    // console.log(val)
    setString(val)
  }

  // ...other code

  return <ReactDropdown
		value={string}
		options={options}
		valueHandler={inputHandler}
		placeholder="Type or select value here. . ."
		error={{ isError: false, errorText: "Error" }}
		// customInputStyles={{}}
		// customDropdownItemStyles={{}}
	/>;
};

🧭 Props

Prop nameDescriptionTypeDefault value
valueInput string to showstring"Sample value"
valueHandlerCallback function that gives back you the updated inputn string value(value: string) => void() => void
placeholderPlaceholder to showstringPlaceholder
errorAn error object, containing props for when to show error string and error string{ isError: boolean, errorText: string }{ isError: false, errorText: '' }
customInputStylesCSS style objectReact.CSSPropertiesundefined
customDropdownItemStylesCSS style objectReact.CSSPropertiesundefined

🐞 Issues

πŸ† Author

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago