Package Exports
- react-dropdown-package
- react-dropdown-package/dist/index.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 (react-dropdown-package) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
React Dropdown Package
A simple and customizable dropdown component for React applications.
Tech Stack
Component: React, Typescript, TailwindCSS
Installation
Install react-dropdown-package with npm
npm install react-dropdown-package
cd react-dropdown-packagePrerequisites
To deploy this project you need to have :
- typescript@>=2.7
npm install typescript- fontawesome for icons
npm install @fortawesome/react-fontawesome @fortawesome/free-solid-svg-iconsUsage
import React, { useState } from "react";
import Dropdown from "react-dropdown-package";
import "./your-custom-styles.css";
const options = [
{ value: "option1", label: "Option 1" },
{ value: "option2", label: "Option 2" },
{ value: "option3", label: "Option 3" },
];
const App = () => {
const [selected, setSelected] = useState(options[0].value);
const handleSelect = (selectedValue) => {
setSelected(selectedValue);
console.log(selectedValue);
};
return (
<Dropdown
options={options}
selected={selected}
onSelectedChange={handleSelect}
placeholder="Please select an option"
isDisabled={false}
customClasses={{
container: "my-dropdown",
button: "my-toggle",
list: "my-menu",
listItem: "my-item",
chevron: "my-chevron",
}}
buttonWidth={150} // Example of custom button width
listWidth={200} // Example of custom list width
buttonHeight={40} // Example of custom button height
listHeight={200} // Example of custom list height
customIcons={{
chevron: <MyCustomChevronIcon />
}}
onOpen={() => console.log('Dropdown opened')}
onClose={() => console.log('Dropdown closed')}
/>
);
};
export default App;Props
Props
Pas de problème, voici les tableaux formatés en Markdown en anglais :
Props
| Prop Name | Type | Description |
|---|---|---|
options |
array | The options for the dropdown. |
selected |
string | The currently selected value. |
onSelectedChange |
function | Function called when an option is selected. |
placeholder |
string | Default text displayed when nothing is selected. |
isDisabled |
boolean | Disables the dropdown if true. |
customClasses |
object | Custom CSS classes for the component. |
customIcons |
object | Custom icons for the component. |
onOpen |
function | Function called when the dropdown is opened. |
onClose |
function | Function called when the dropdown is closed. |
buttonWidth |
number | Width of the dropdown button in px (optional). |
buttonHeight |
number | Height of the dropdown button in px(optional). |
listWidth |
number | Width of the dropdown list in px (optional). |
listMaxHeight |
number | Max Height of the dropdown list in px (optional). |
customClasses Object Structure
| Key | Type | Description |
|---|---|---|
container |
string | CSS class for the dropdown container. |
button |
string | CSS class for the toggle button. |
list |
string | CSS class for the dropdown menu. |
listItem |
string | CSS class for the dropdown menu items. |
chevron |
string | CSS class for the chevron icon. |
customIcons Object Structure
| Key | Type | Description |
|---|---|---|
chevron |
ReactNode | Custom icon for the chevron. |
Licence
This project is licensed under the MIT License. See the LICENSE file for more details