Skip to content

Repository files navigation

Code Practice

Demo

https://morning-eyrie-25991.herokuapp.com/

Options

PropertyTypeDefaultDescription
valuestringThe selected value (required)
optionsarray[]The dropdown options. (required)
classPrefixstring'Select'You can use your own stylesheet with different class name prefix
classNamestringAdditional class name
optionComponentelementYou can customize the option style by using this prop. (optional)
onChangefunconChange callback

Example

importReact,{Component}from'react';importSelectfrom'../components/Select';import'../components/Select/style.scss';// Default stylesheetclassAppextendsComponent{constructor(props){super(props);this.state={selectedValue: 1};}render(){return(<Selectvalue={this.state.selectedValue}optionComponent={props=>(<spantitle={props.label}><spanclassName="CustomSelect-dot"style={{background: props.color}}/>{props.label}</span>)}options=[{value: '1',label: 'Option 1',color: 'yellow'},{value: '2',label: 'Option 2',color: 'blue'},{value: '3',label: 'Option 3',color: 'pink'}]/>)}}

Installation

Clone it from GitHub

git clone git@github.com:josephj/react-simple-select.git;

Go into the folder

cd react-simple-react;

Install the packages. You can run npm install if you don't have yarn.

yarn

Run the web server. You can run npm start if you don't have yarn.

yarn start

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages