1.1.8 • Published 10 months ago

react-turbo-select v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

🚀 ✴️ React Turbo Select ✴️ 🚀

NPM Downloads npm NPM License npm collaborators

🚀 Turbo Select, a cutting-edge and versatile React component, delivers an unparalleled dropdown select menu for your applications. Seamlessly cater to your needs, whether it's a seamless single selection or a dynamic, multi-faceted choice with tags. 💡 Empowered with a plethora of customization options, Turbo Select adapts effortlessly to a diverse array of use cases. Tailor it to perfection and unlock endless possibilities for your projects. 💻💪

🔍 Preview

LIGHT MODEDARK MODE
npm.ionpm.io
npm.ionpm.io
npm.ionpm.io

🛠️ Installation

To install Turbo Select in your React project, you can use npm or yarn:

npm install react-turbo-select

or

yarn add react-turbo-select

⚙️ Props and APIs

Turbo Select accepts the following props:

⚙️ Props💡 Description
isSearchableEnable searching/filtering options.
isLoadingShow loading indicator when options are being loaded asynchronously.
isClearableAllow clearing the selected option(s).
isMultipleAllow multiple option selection.
showTagsControlsShow tags for selected options when in multiple selection mode.
isDisabledDisable the select component.
closeOnSelectClose the dropdown menu after selecting an option.
menuOpenInitial state of the dropdown menu (open or closed).
noOptionsMessageCustom message to display when no options are available.
loadingMessageCustom message to display when options are loading.
autoFocusAutomatically focus on the input when the component mounts.
onMenuOpenCallback function when the dropdown menu opens.
onMenuCloseCallback function when the dropdown menu closes.
onReachMaxScrollCallback function when the menu reaches its maximum scroll position.
openMenuOnClickOpen the menu when clicking on the component.
escapeCloseMenuAllow closing the menu when pressing the escape key.
isRtlSet the component to support right-to-left languages.
dropDownIconCustom icon to display as the dropdown indicator.
defaultMenuIsScrollableEnable scrolling in the dropdown menu by default.
optionsAn array of Option objects (interface defined in the package).
* if this provided it will override optionsGroups prop
optionsGroupsAn array of OptionGroup objects (interface defined in the package).
* this prop will be neglected in case of options prop existed
getContainerRefCallback function to get the reference of the container element.
getInputRefCallback function to get the reference of the input element.
getMenuRefCallback function to get the reference of the dropdown menu element.
containerStylesCustom styles for the main container element.
inputStylesCustom styles for the input element.
menuStylesCustom styles for the dropdown menu.
optionStylesCustom styles for the options in the dropdown menu.
defaultValueThe default selected option(s).
onChangeCallback function when the selected option(s) change.
placeholderPlaceholder text for the input.
widthWidth of the select component (default: 300).
heightHeight of the select component (default: 40).
menuHeightMaximum height of the dropdown menu (default: 250).
iconFlickerEnable icon flickering animation (default: false).
borderRadiusBorder radius for the select component (default: "tiny").
gapBetweenControlsGap between the controls (tag and dropdown icon) (default: 10).
tagStyleCustom styles for the tags in multiple selection mode.
modeColor mode of the select component ("light" or "dark") (default: "light").

🎮 Demo

check out our live demo ↗ to see some more advanced examples of how to use my package in the real world.

🎉 Getting Started

To get started with Turbo Select, simply import the component into your project:

import { TurboSelect } from 'react-turbo-select'

📖 Usage

Here's a quick example of how you can use Turbo Select in your React application:

📌 using it with options prop

import React from 'react'
import { TurboSelect } from 'react-turbo-select'

const options = [
  { value: '1', label: 'Option 1' },
  { value: '2', label: 'Option 2' },
  { value: '3', label: 'Option 3' },
  // Add more options as needed
]

const MyComponent = () => {
  // Your component logic here
  return (
    <div>
      <h1>My Awesome App</h1>
      <TurboSelect options={options} />
      {/* Add more components and logic */}
    </div>
  )
}

export default MyComponent

📌 using it with optionsGroups prop

import React from 'react'
import { TurboSelect } from 'react-turbo-select'

const optionsGroups = {[
          {
            groupName: 'First Group',
            groupValues: [
              { label: 'React', value: 'react' },
              { label: 'Vite', value: 'vite' },
              { label: 'Ahmed', value: 'ahmed' },
              { label: 'Mohamed', value: 'mohamed' },
            ],
          },
          {
            groupName: 'Second Group',
            groupValues: [
              { label: 'Khaled', value: 'khaled' },
              { label: 'Ali', value: 'ali' },
              { label: 'Maher', value: 'maher' },
              { label: 'Moheb', value: 'moheb' },
            ],
          },
          {
            groupName: 'Third Group',
            groupValues: [
              { label: 'Mahmoud', value: 'mahmoud' },
              { label: 'Nour', value: 'nour' },
              { label: 'Salah', value: 'salah' },
              { label: 'Ameer', value: 'ameer' },
            ],
          },
        ]}

const MyComponent = () => {
  // Your component logic here
  return (
    <div>
      <h1>My Awesome App</h1>
      <TurboSelect optionsGroups={optionsGroups} />
      {/* Add more components and logic */}
    </div>
  )
}

export default MyComponent