|
1 | | -# dropdown-search-checkbox-javascript |
| 1 | +# Dropdown with Search and Checkboxes |
| 2 | + |
| 3 | +A simple and customizable dropdown menu with a built-in search bar and checkboxes for multiple selections. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- 🔍 **Searchable**: Quickly filter items by typing in the search box. |
| 8 | +- ✅ **Multi-Select**: Select multiple items using checkboxes. |
| 9 | +- 📌 **Click Anywhere**: Click on the item text or checkbox to toggle selection. |
| 10 | +- 🎨 **Customizable**: Easy to modify styles and functionality. |
| 11 | + |
| 12 | +## Demo |
| 13 | + |
| 14 | +\ |
| 15 | +*Example of the dropdown in action.* |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +1. **Clone the repository** |
| 20 | + ```sh |
| 21 | + git clone https://github.com/your-username/dropdown-search-checkbox.git |
| 22 | + cd dropdown-search-checkbox |
| 23 | + ``` |
| 24 | +2. **Open **``** in a browser** |
| 25 | + ```sh |
| 26 | + open index.html |
| 27 | + ``` |
| 28 | + |
| 29 | +## Usage |
| 30 | + |
| 31 | +Include the following HTML structure in your project: |
| 32 | + |
| 33 | +```html |
| 34 | +<div class="selectDropdown"> |
| 35 | + <div class="selectDropdownToggle"> |
| 36 | + <div class="dropdown-toggle__title"> |
| 37 | + <span>Select Continent/Region</span> |
| 38 | + <img src="./chevron-up.svg"> |
| 39 | + </div> |
| 40 | + </div> |
| 41 | + <div class="selectDropdownMenu"> |
| 42 | + <div style="padding: 1rem;"> |
| 43 | + <input type="text" id="searchBox" placeholder="Search..."> |
| 44 | + <div id="selectDropdownItems"> |
| 45 | + <div class="selectDropdownItem"><span>Apple</span> <input type="checkbox" value="Apple"></div> |
| 46 | + <div class="selectDropdownItem"><span>Banana</span> <input type="checkbox" value="Banana"></div> |
| 47 | + <div class="selectDropdownItem"><span>Cherry</span> <input type="checkbox" value="Cherry"></div> |
| 48 | + </div> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | +</div> |
| 52 | +``` |
| 53 | + |
| 54 | +## Customization |
| 55 | + |
| 56 | +### Change Dropdown Width |
| 57 | + |
| 58 | +Modify the `.selectDropdown` CSS class: |
| 59 | + |
| 60 | +```css |
| 61 | +.selectDropdown { |
| 62 | + width: 300px; /* Change to desired width */ |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +### Update Colors |
| 67 | + |
| 68 | +Change border and hover colors in `.selectDropdownItem:hover`: |
| 69 | + |
| 70 | +```css |
| 71 | +.selectDropdownItem:hover { |
| 72 | + background: rgba(47, 139, 138, 0.1); |
| 73 | + color: #2F8B8A; |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +## JavaScript Functionality |
| 78 | + |
| 79 | +- **Toggle Dropdown**: Opens/closes dropdown on click. |
| 80 | +- **Search Filter**: Filters items based on search input. |
| 81 | +- **Checkbox Toggle**: Click anywhere on the item to toggle selection. |
| 82 | +- **Close on Outside Click**: Automatically closes the dropdown when clicking outside. |
| 83 | + |
| 84 | +## Contributing |
| 85 | + |
| 86 | +1. Fork the repository. |
| 87 | +2. Create a new branch (`feature-new-feature`). |
| 88 | +3. Commit your changes (`git commit -m 'Add new feature'`). |
| 89 | +4. Push to the branch (`git push origin feature-new-feature`). |
| 90 | +5. Open a Pull Request. |
| 91 | + |
| 92 | +## License |
| 93 | + |
| 94 | +This project is licensed under the MIT License. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +Made with ❤️ by [Your Name](https://github.com/your-username) |
| 99 | + |
0 commit comments