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

react-dropdown-z

v6.1.0

Published

React hook. Simple dropdown. (Lib)

Readme

NPM JavaScript Style Guide Downloads


Description

  • Simple, quick dropdown (group) for react.
  • Append perfect scrollbar. (if need)
  • Support show top, hide.
  • Fit to window size if exceeding the height beyond the window.
  • Auto change show top or bottom. (if need).
  • Add tooltip if-need rc-tc-ifn
  • If you want more, please use react-select.

Usage

Install the package

npm i react-dropdown-z

Import the module in the place you want to use:

import "react-dropdown-z/build/styles.css";
import Dropdown from "react-dropdown-z";

Snippet

    const [value, setValue] = React.useState();

    // flat options
    const options = [ "o1", "tw2", "th3", "f4" ];

    <Dropdown
      // placeholder="Abcd"
      options={options}
      width="200px"
      enablePerfectScroll // if need
      // dropdownHeight="100px" // fit with window
      value={value}
      handleSelection={setValue}
      showAbove
    />
    // Object array
    // keyName and labelName
    const options2 = [
      { dsds: 'dsd' }, // => please set key and value => display json
      {
        val: 0,
        text: 'this one',
      },
      {
        val: 2,
        text: 'this one 2',
      },
      {
        val: 3,
        text: 'this one 3',
        className: 'class-3'
      },
      {
        val: 10,
        text: 'this one 10 this is option tooltip abcd xyz',
        disabled: true
      },

      // group
      {
        isGroup: true,
        groupName: 'group a',
        className: 'groupclass'
        items: [
          {
            val: 4,
            text: 'this one 4',
          },
        ],
      },
    ]

    <Dropdown
      // placeholder="Abcd"
      keyName="val"  // only set when array option is object
      labelName="text" // only set when array option is object
      options={options2}
      width="200px"
      value={value}
      handleSelection={setValue}
      // resizeClose={false}
      showAbove
      tooltipIfLabelProps={{
        placement: 'right',
        width: '100%',
      }}
      tooltipIfDropdownProps={{
        placement: 'right',
        width: '100%',
      }}
    />

props

| Prop Name | Type | Description | |--------------------------|-------------------------------------------------------|------------------------------------------------------------------| | className | string | Custom class for the root container. | | arrowClassName | string | Custom class for the dropdown arrow. | | groupItemClassName | string | Custom class for grouped items. | | dropdownClassName | string | Custom class for the dropdown list container. | | placeholderClassName | string | Custom class for the placeholder. | | showAbove | boolean | Whether the dropdown should appear above the trigger. | | options | IFGroupData[] \| any[] | Array of selectable options. | | keyName | string | Key name used to extract the value from an option object. | | labelName | string | Key name used to extract the label from an option object. | | value | string \| number \| null | Currently selected value. | | customizeArrow | string \| React.ReactNode | Custom arrow icon/component. | | placeholder | string | Placeholder text when no value is selected. | | noDataText | string | Text to display when options is empty. | | width | string \| number | Width of the dropdown component. | | height | string \| number | Height of the select box (not the dropdown). | | fullWidth | boolean | If true, makes the component stretch to 100% width. | | enablePerfectScroll | boolean | Enables perfect-scrollbar integration for dropdown scrolling. | | tabIndex | number | Sets tab index for accessibility. | | disabled | boolean | Disables the dropdown when true. | | dropdownHeight | string \| number | Explicit height for the dropdown list. | | fitToWindowHeight | boolean | Dropdown resizes to fit within visible window area. | | autoAdjustDirection | boolean | Automatically flips dropdown direction based on available space. | | preserveScrollPosition | boolean | Retains scroll position in dropdown between opens. | | closeOnResize | boolean | Closes dropdown when window is resized. | | closeOnEscape | boolean | Closes dropdown when Escape is pressed. | | closeOnOutside | boolean | Closes when clicking outside the dropdown. | | tooltipIfLabelProps | IFTooltipLabelProps | Tooltip props for the label. | | tooltipIfDropdownProps | IFTooltipDropdownProps | Tooltip props for the dropdown content. | | handleSelection | (value: string \| number \| null, selectItem?: any) => any | Callback when an option is selected. |

Note

tooltipIfProps: react-tooltip-z / rc-tc-ifn

RUN

LIVE EXAMPLE

License

MIT