react-dependent-dropdown
Version:
Custom dependent dropdown for react application.
47 lines (34 loc) • 1.22 kB
Markdown
> Made with create-react-library
[](https://www.npmjs.com/package/react-dependent-dropdown) [](https://standardjs.com)
```bash
npm install --save react-dependent-dropdown
```
```jsx
import React, { Component } from 'react'
import DependentDropdown from 'react-dependent-dropdown'
class Example extends Component {
render() {
// Fetch from api
const categories = ['Electronics', 'Clothing', 'Books']
// Fetch from api
const subcategories = {
Electronics: ['Laptops', 'Smartphones', 'Cameras'],
Clothing: ['T-shirts', 'Jeans', 'Dresses'],
Books: ['Fiction', 'Non-fiction', 'Science']
}
return (
<DependentDropdown
categoriesList={categories}
subcategoriesData={subcategories}
categoryClass='custom-category' // Apply custom styles to category dropdown
subcategoryClass='custom-subcategory' // Apply custom styles to subcategory dropdown
/>
)
}
}
```
MIT © [remonhasan](https://github.com/remonhasan)