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

react-marcat-dropdown

v1.0.5

Published

A simple dropdown component

Downloads

12

Readme

React-Marcat-Dropdown

Requirements

Before getting started, make sure you have the following installed:

Used

Styled-component was used on this project, please check if there are any compatibility issues before importing the component.

Installation

Install this package:

npm install react-marcat-dropdown

Import the DropdownInput component:

import DropdownInput  from "react-marcat-dropdown/dropdown";

Description

This component renders a custom dropdown input that can be used to select one option from a list of options. The component is implemented using styled-components and is fully customizable.

Props

  • name: string (required) - The name of the input.
  • data: string[] (required) - An array of strings that represents the list of options.
  • personnalId: string (optional) - Id for the selector.
  • defaultText: string (optional) - The default text that appears in the dropdown before an option is selected.
  • fontSize: string (optional) - The font size for the dropdown. Defaults to "1em".
  • color: string (optional) - The color of the selected option text. Defaults to "rgba(0,0,0,0.25)".
  • borderColor: string (optional) - The color of the dropdown border. Defaults to "1px solid rgba(0,0,0,0.25)".
  • borderRadius: string (optional) - The border radius of the dropdown. Defaults to "5px".
  • scrollBarBackgroundColor: string (optional) - The background color of the scrollbar. Defaults to "rgba(0,0,0,0.25)".
  • scrollBarThumbColor: string (optional) - The color of the scrollbar thumb. Defaults to "rgba(0,0,0,0.5)".
  • scrollBarWidth: string (optional) - The width of the scrollbar. Defaults to "8px".
  • scrollBarRadius: string (optional) - The border radius of the scrollbar. Defaults to "10px".
  • selectBoxColor: string (optional) - The background color of the dropdown options. Defaults to "#ffffff".
  • selectBoxOptionsColor: string (optional) - The color of the dropdown options text. Defaults to "rgba(0,0,0,0.25)".
  • labelled: boolean (optional) - Whether to include a label for the input. Defaults to false.

State

The component uses the useState hook to keep track of the selected option. When an option is selected, the state is updated accordingly.

Functions

  • handleChange: This function is called whenever the selected option changes. It updates the state with the new selected option.

Usage

import React from 'react';
import DropdownInput  from "react-marcat-dropdown/dropdown";

const options = ['Option 1', 'Option 2', 'Option 3'];

const MyComponent = () => {
  return (
    <DropdownInput
      name="myDropdown"
      data={options}
      defaultText="Select an option"
      color="red"
      borderColor="2px solid red"
      borderRadius="10px"
      scrollBarBackgroundColor="#f0f0f0"
      scrollBarThumbColor="#c5c5c5"
      scrollBarWidth="12px"
      scrollBarRadius="20px"
      selectBoxColor="#ebebeb"
      selectBoxOptionsColor="#333333"
      labelled
      personnalId="selector"
      fontSize="1em"
      required
    />
  );
};

In the above example, a DropdownInput component is rendered with some custom props. The options array is passed as the data prop to populate the dropdown. The defaultText, color, borderColor, borderRadius, scrollBarBackgroundColor, scrollBarThumbColor, scrollBarWidth, scrollBarRadius, selectBoxColor, and selectBoxOptionsColor props are used to customize the appearance of the dropdown. Finally, the labelled prop is set to true to include a label for the input.