react-dependent-dropdown
v1.0.3
Published
Custom dependent dropdown for react application.
Downloads
5
Maintainers
Readme
react-dependent-dropdown
Made with create-react-library
Install
npm install --save react-dependent-dropdown
Usage
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
/>
)
}
}
License
MIT © remonhasan