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 🙏

© 2024 – Pkg Stats / Ryan Hefner

npm-native-dropdown

v1.0.6

Published

The native-dropdown package provides a versatile and customizable dropdown component for React applications. With this package, you can easily integrate dropdown menus into your UI, offering users a seamless way to select options from a list.

Downloads

435

Readme

npm-native-dropdown

The npm-native-dropdown package provides a versatile and customizable dropdown component for React applications. With this package, you can easily integrate dropdown menus into your UI, offering users a seamless way to select options from a list.

Badges

MIT License

Installation

Install my-project with npm

  npm install npm-native-dropdown
  cd my-project

or

  yarn add npm-native-dropdown
  cd my-project

Features

  • Easy to use
  • Single or Multiselect option for items
  • Responsive for Cross platform
  • Have wast option for customization
  • Implemented with typescript

Screenshots

App gif

Array example -

  const options = [
    "Heart",
    "Thumbs Up",
    "Star",
    "Smiley",
  ];

npm Import -

import DropdownMenu from 'npm-native-dropdown';

Usage/Examples 1 - Simple

      <DropdownMenu
        placeHolder={selected ? selected : 'Select Option'}
        options={options}
        onSelect={(selectedItem: string, index: number) => {
          console.log('>>>', selectedItem, index);
        }}
      />

Usage/Examples 2 - With renderitem and renderButton

      <DropdownMenu
        options={options}
        onSelect={(selectedItem: string, index: number) => {
          console.log('>>>', selectedItem, index);
        }}
        renderButton={(buttonRef, toggleMenu) => {
          return (
            <TouchableOpacity style={[$button]} ref={buttonRef} onPress={toggleMenu}>
              <Text>{selected ? selected : 'Select'}</Text>
            </TouchableOpacity>
          )
        }}
        renderItem={(setIsMenuOpen: () => any) => {
          return options.map((option, index) => {
            return (<TouchableOpacity
              key={index}
              onPress={() => {setIsMenuOpen(),setSelected(option)}}
              style={[$menuItem(options?.length === index + 1)]}
            >
              <Text style={[$textStyle]}>{option} </Text>
            </TouchableOpacity>)
          })
        }}
      />
      
const $menuItem = (isLast: boolean): ViewStyle => ({
  padding: 12,
  flex: 1,
  paddingVertical: 8,
  width: 200,
  borderBottomWidth: isLast ? 0 : 0.5,
  borderColor: 'gray',
  alignItems: 'center'
})

const $textStyle: TextStyle = {
  fontSize: 16,
  fontWeight: '400',
  color: 'green'
}

const $button: TextStyle = {
  backgroundColor: '#e1ecf7',
  height: 44,
  width: 200,
  borderColor: '#71a5de',
  borderWidth: 1,
  borderRadius: 4,
  alignItems: 'center',
  justifyContent: 'center',
}

Usage/Examples 3 - With Icons

(Note - You can use any JSX.Element)

      <DropdownMenu
        placeHolder={selected ? selected : 'Select Option'}
        options={options}
        onSelect={(selectedItem: string, index: number) => {
          console.log('>>>', selectedItem, index);
        }}
        leftRenderIcon={
          <Image
            style={$tinyLogo}
            source={{
              uri: 'https://image.png',
            }}
          />
        }
        rightRenderIcon={
          <Image
            style={$tinyLogo}
            source={{
              uri: 'https://image.png',
            }}
          />
        }
      />

const $tinyLogo: ImageStyle = {
  width: 20,
  height: 20,
}

API Reference

Props

| Props | Params | isRequire | Description | | :-------- | :------- | :--------- | :------------------------- | | options | string[] | Yes | Plain array containing dropdown options.| | rightRenderIcon | ReactElement | No | Custom component to be used as the dropdown icon.| | placeHolder | string | No | Placeholder text when no option is selected.| | onSelect | (option: string, index: number) => void | Yes | function recieves selected item and its index in data array| | disabled | boolean | No | disable dropdown| | buttonStyle | ViewStyle | No | style object for dropdown Button.| | placeHolderTextStyle | TextStyle | No | style object for dropdown placeholder Text.| | contentStyle | ViewStyle | No | style object for dropdown content.| | menuItemStyle | ViewStyle | No | style object for dropdown menu items.| | optionStyle | TextStyle | No | style object for dropdown options.| | leftRenderIcon | JSX.Element | No | Custom component to be used as the dropdown icon.| | renderItem | JSX.Element | No | React component for each dropdown item.| | renderButton | JSX.Element | No | React component for the dropdown button.| | dropDownWidth | number | No | dropdown width.|

Author

License

MIT