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

tiny-dropdown

v1.0.0

Published

A simple, customizable, light-weight dropdown component built with love using React

Downloads

2

Readme

tiny-dropdown -- React

A simple, customizable, light-weight dropdown component built with love using React.

This project was bootstrapped with Create React App & Storybook.

Live demo here: https://rehman-00001.github.io/tiny-dropdown

Installation

npm install tiny-dropdown or yarn add tiny-dropdown

Usage

import TinyDropdown from 'tiny-dropdown';

Data type - Strings :

const options = [ 'Google', 'Microsoft', 'Amazon', 'Facebook', 'Twitter', 'Uber' ];
<TinyDropdown
    options={options}
    onSelect={(option, selectedIndex) => alert(option, selectedIndex)}
    placeHolder="Select a company"
    visibleOptions={4}
    selectedIndex={2}
/>

Data type - Objects :

const options = [
{
  key: 'option-1',
  value: 'United States'
},
{
  key: 'option-2',
  value: 'Russia'
},
{
  key: 'option-3',
  value: 'India'
},
{
  key: 'option-4',
  value: 'China'
}]

<TinyDropdown
    options={options}
    label={option => option.value}
    onSelect={(option, selectedIndex) => alert(option, selectedIndex)}
    placeHolder="Select your country"
    visibleOptions={3}
    selectedIndex={2}
/>

Properties

placeHolder - Placeholder text for the dropdown. By default it shows: "Select an option".

options - An array of options for the dropdown menu. Items can either be Strings or Objects. In case of objects, the property "label" is mandatory.

label - A function which is executed on every object in "options" array. Returned value is a string representing that object is shown in the UI.

selectedIndex - If any option has to be selected initially, pass the index of that option as "selectedIndex". It will be marked as selected.

onSelect() - A handler function which will be called when user selects any option from the dropdown menu. Input parameters: selectedOption, selectedIndex.

visibleOptions - Defines the number of options that are visible without the need of scrolling down. By default 8 items are visible.

panelOnly - If set to true, expanding the panel just hides the dropdown button. Only the options panel is displayed.

cssOverrides - Specifies the styles to be overridden. It has 4 sub-properties:

  dropdownButton - Overrides the styles for dropdown itself.
  dropdownPanel - Overrides the styles for the dropdown popup panel.
  dropdownOption - Overrides the styles for every single option in the popup panel.
  dropdownOptionSelected - Overrides the styles for selected option in the popup panel.

Features Planned

~~Add support to customize CSS styles~~ Fitler support for options Custom HTML for options Load data from ajax Selected element styles CSS animations & Much more to come