Package Exports
- ru-react-dropdown-component
- ru-react-dropdown-component/dist/index.es.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ru-react-dropdown-component) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
reusable-react-dropdown-component
The ru-react-dropdown-component library provides the DropDownBox component, a customizable and feature-rich dropdown selector for React applications. This documentation outlines its props, behavior, and usage.
Demo and DOCS 👇
👉 ru-react-dropdown-component.vercel.app
Usage Example
import React, { useState } from "react";
import DropDownBox from "ru-react-dropdown-component";
// Importing CSS is optional. However, if you notice a slight delay in
// styles being applied, consider importing it for better performance.
import "ru-react-dropdown-component/dist/styles.css";
const MyComponent = ({ country }) => {
const [selectedValue, setSelectedValue] = useState("");
const options = [
{ label: "Option 1", value: "option1" },
{
label: "Option 2",
value: "option2",
// Additional searchable values for this option
searchOptions: ["xyz@email.com", "123-456-789"],
},
];
return (
<DropDownBox
title="Select City"
animateTitle={true}
options={options}
placeholder="Choose..."
size="medium"
showSearch={true}
onSelect={(value, context) => {
console.log(value, context);
}}
beforeSelect={(value, context) => {
console.log(value, context);
}}
afterSelect={(value, context) => {
console.log(value, context);
}}
changeObserver={{
target: country,
handler: (setter, context) => {
if (context.dropdownValue) {
setter("");
}
},
}}
styles={{
selectBox: { border: "1px solid #ccc" },
selectedValue: { color: "blue" },
}}
resetButton={true}
/>
);
};
export default MyComponent;Notes
- Ensure to provide required props such as
optionsandonSelectfor proper functionality. - The component is designed to be flexible with various styling and functionality customizations.
Props
titleanimateTitleoptionsplaceholderwidthcustomArrowdisabledloadinghideScrollbarincomingValueresetButtononSelectbeforeSelectafterSelectonOpenshowSearch
delayonSearchplaceholder
changeObserver
targethandler
scrollListenerTarget
idclassNameref
styles
selectBoxselectedValueplaceholdertitlearrowdisabledStateoptionsContaineroptionItemsearchInput