You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-switchbox

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-switchbox

Dropdown and search component for React applications.

1.3.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

switchbox

A dropdown, and search component for React applications

Install

npm install --save react-switchbox

Usage

import Switchbox from 'react-switchbox'

Prop Types

The switchbox component takes one prop type: options

Options

The options prop is an object detailing all the rules for the switchbox Here is an example options object prop:

const options = this.props.options || {
    type: 'dropdown',
    data: ['things', 'to', 'display']
    iconPosition: 'right',
    hideIcon: false,
    defaultValue: 'drop for something.',
    maxItems: 10,
    itemHeight: 22,
    onChange: (searchQuery) => { console.log(`${searchQuery} is being returned`) },
    onSelect: (selectedItem) => { console.log(`user has selected ${selectedItem}`) }
}
The object can contain:

type: Either dropdown or search, defaults to dropdown

data: The data that will be used in the search or dropdown

iconPosition: Either left or right, defaults to right

hideIcon: true or false, defaults to true

defaultValue: The default text displayed in the switchbox

maxItems: A limit on how many items can be displayed, defaults to 10

itemHeight: The height of each item in the dropdowns

onChange: A callback that return the text typed into the switchbox. this is used to filter and refine your search ( must be implemented yourself )

onSelect: A callback that returns the value of the item selected in the dropdown of the switchbox.

Implement

export default class App extends Component {
  render () {
    return (
      <Switchbox options={options}/>
    )
  }
}

License

© Perple Corp.

Author: Kyle Kilbride

FAQs

Package last updated on 09 Nov 2018

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.