Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@coopdigital/component-searchable-dropdown

Package Overview
Dependencies
Maintainers
7
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coopdigital/component-searchable-dropdown

Co-op Component: Searchable Dropdown

latest
Source
npmnpm
Version
0.2.7
Version published
Maintainers
7
Created
Source

Searchable Dropdown

A Co-op styled searchable dropdown (aka combobox) React component built using Downshift.

Installation

Install via npm or yarn:

npm install @coopdigital/component-searchable-dropdown

yarn add @coopdigital/component-searchable-dropdown

Prerequisites

You must have the Co-op foundations and foundations-forms css packages installed in your project. You will also need React 17 or higher.

@import "@coopdigital/foundations/dist/vars/vars.css";
@import "@coopdigital/foundations/dist/foundations.css";
@import "@coopdigital/foundations-forms/dist/forms.css";

Importing

@import "@coopdigital/component-searchable-dropdown/dist/styles.css";
import { SearchableDropdown } from "@coopdigital/component-searchable-dropdown";

Basic Usage

<SearchableDropdown
  label="My favourite animal is a..."
  id="animals"
  options={["Cat", "Dog", "Frog", "Panda", "Sloth"]}
/>

Required props

These props are required for the component to render:

proptypedescription
labelstringText for the associated element label.
idstringA unique identifier for the element.
optionsarrayArray of strings to use for option values

Additional props

The component can be further customised using the props below:

proptypedescriptiondefault
classNamestringAdditional class (or classes) to append to the outer coop-c-combobox element-
compactboolReduces the input font size to 1remfalse
noResultsstringString to display when no matching options are foundNo relevant options
onSelectfuncCallback function when an option is selected, receives the selected value as its only parameter-
placeholderstringPlaceholder text to display when no option is selected-
styleobjectCSS object with inline styles to be added to the outer coop-c-combobox element-

Kitchen sink

<SearchableDropdown
  label="My favourite animal is a..."
  id="animals"
  options={["Cat", "Dog", "Frog", "Panda", "Sloth"]}
  className="additional-class another-class"
  compact
  placeholder="Select option"
  onSelect={(value) => {
    console.log(value);
  }}
  style={{ width: "300px" }}
/>

License

Copyright (c) 2022 Co-operative Group Limited. Licensed MIT.

Keywords

combobox

FAQs

Package last updated on 21 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts