npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@redshark61/dropdown

v1.0.8

Published

Dropdown react component

Readme

Dropdown

Introduction

This component is a dropdown that allows you to select one or more items from a list. It is fully customizable and can be used in any React project. In addition to providing a great amount of classes and styles, the component also provides a lot of props to handle the dropdown behavior, such as onSelectionChange to handle the selection of an item, or a hidden input to store the selected items.

Preview

Here you have a preview of the most basic dropdown without any customization. img.png

Minimum requirements

The component requires the following props:

  • items ({id: string; value: string;}[]): an array of objects containing the items to display in the dropdown.
  • id (string): the id of the hidden input that will store the selected items.
  • label (string): the label of the dropdown. Only required if displayLabel is true. displayLabel is true by default meaning that the label is also required by default.

Customization

All available class:

<DropDown 
    items={items}
     id={"id"}
     label={"Test Label"}
     placeholder={"Test Button"}
     dropdownClass={"border-black"}
     boxClass={"border-red"}
     headerClass={"border-blue"}
     listClass={"border-green"}
     itemClass={"border-purple"}
     labelClass={"color-red"}
/>

img_1.png

In addition to their corresponding class, you can pass the same attribute with the style suffix instead of classto customize the dropdown more precisely (e.g boxStyle instead of boxClass).

 <DropDown                            
  items={items}                        
  id={"id"}                            
  label={"Test Label"}                 
  placeholder={"Test Button"}          
  headerClass={"border-blue"}          
  itemStyle={{backgroundColor: "red"}} 
  />                                   

img.png

Example

JSX

<DropDown 
    items={items}
     id={"id"}
     label={"Test Label"}
     placeholder={"Test Button"}
     dropdownClass={"dropdown"}
     boxClass={"box"}
     headerClass={"header"}
     headerStyle={{opacity: 1}}
     listClass={"list"}
     itemClass={"item"}
     labelClass={"label"}
     labelStyle={{fontSize: "1.5rem"}}
/>

CSS


.dropdown{
    width: 300px;
    margin: 40% auto auto;
}

.box{
    background: darkslateblue;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.header{
    color: white;
}

.list{
    width: 100%;
}

.label{
    color: darkslateblue;
}
.item{
    background: white;
}

img_2.png

Other props

  • multiSelect (boolean): if true, the dropdown will allow multiple selection. If false, only one item can be selected at a time. The default value is false.

    multiSelect={true}: img_3.png

  • displayArrow (boolean): if true, the arrow icon will be displayed. If false, the arrow icon will be hidden. The default value is true.

    displayArrow={false}: img_4.png

  • displayLabel (boolean): if true, the label will be displayed. If false, the label will be hidden. The default value is true.

    displayLabel={false}: img_5.png

  • displayReset (boolean): if true, the reset button will be displayed. If false, the reset button will be hidden. The default value is true.

    displayReset={false}: img_6.png

  • position ("top" | "bottom"): the position of the dropdown box. The default value is bottom.

    position={"top"}: img_7.png

  • customImage (string) : change the arrow icon.

    customImage={"./src/assets/arrow.png"}: img_8.png