🛠 Highly customisable, minimalistic input x select field for React.

Overview

Insect



insect logo

🛠 Highly customisable, minimalistic input x select field for React.

Package version. Make a pull request.


⚡️ Features

  • Tiny size (~4kb Gzip)
  • 100% responsive.
  • Highly customisable.
  • Supports custom rem unit.
  • Zero third party dependency (asides react's recommended prop-types).
  • Typescript ready
  • Multi select options
  • Options search
  • Custom icons support


💾 Installation

$ yarn add react-insect


📄 Basic Usage

// Import Insect component
import { Insect } from 'react-insect';

// Use it in your code like so
export const MyComponent = () => {
  return (
    <>
      <Insect
        name="username"
        type="text"
        placeholder="Choose a username"
      />
    </>
  );
};


🪄 Props

Insect can be either an input field, a single select field or a multi select field. The props passed in determines what Insect is. Here's a table of all available props for input and for select.



🧩 General props

Prop Description Type default
name Sets the name of the input field. string
type Sets type of input field text | number | password | email | select text
label Adds a label to the top of insect component. string
placeholder Sets the placeholder for insect component. string Input or select an option
prefixIcon Adds an icon at the left of insect field string | React.ReactNode | null
suffixIcon Adds an icon at the right of insect field string | React.ReactNode | null
className Custom classname for main insect container string
labelClass Custom classname for insect label string
inputWrapperClass Custom classname for the input field wrapper div string
inputClass Custom classname for the main input field string
iconsClass Custom classname for all icons string
onFocus Function to trigger when input field is focused on. (e: React.FocusEvent<HTMLInputElement>) => void
onBlur Function to trigger when input field goes out of focus. (e: React.FocusEvent<HTMLInputElement>) => void


🏁 For Input field type

Prop Description Type default
value Sets the value of the input field. string
onChange Sets the placeholder for insect component. (e: React.FormEvent<HTMLInputElement>) => void


🔮 For Select field type

Prop Description Type default
allowMultiple Enables multi select by setting the number of selectable items number
search Toggles option search boolean (false)
options A list of options for the select field { title: string; value: string; }[] [ ]
onSelect Funtion to trigger when an item is selected. It returns the field name and then returns a single string for single select and an array of strings for multi select (value: string | string[] | null, name: string) => void
dropdownIcon Custom icon for dropdown caret string | React.ReactNode | null
checkmarkIcon Custom selected item indicator icon string | React.ReactNode | null
dropdownClass Custom classname for the dropdown container div. This div wraps the ul tag which in turn wraps the individual li tags string
checkerClass Custom classname for the selected items indicator icon string
closeOnBlur Determines if the dropdown should close when outside is clicked or not boolean true


🦄 Usage with custom PX - REM unit

Sometimes, you may want to set the default rem unit to 10rem/1px (or any value at all) by adding font-size: 10px (or some kind of viewport based value) to the html tag in order to simplify rem/px unit conversion. This will cause a lot of problems with third party components but don't worry, insect got you!

Just add the following css variable to your main stylesheet and insect will adapt to your new unit.

:root {
  --insect-rem: 10 !important;
}


👷🏽 Contribution Guide

Insect is an opensource project and public contribution is very welcome. You can check Issues for bugs to fix or features to add.

  1. Fork this repository.
  2. Clone the forked repository to your local machine.
  3. Create a new branch with a name like this - feature/name-of-feature.
  4. Run yarn to install dependencies.
  5. Write code and then commit changes.
  6. Run yarn build to compile a build into the dist folder.
  7. Now You can decide to manually copy the inex.tsx and index.scss file from here into a local project in order to test the feature/bug you have fixed.
  8. Alternatively, run yarn link in your local insect root folder.
  9. On the local project you want to test the features on, run yarn link 'insect'.
  10. Now navigate back to the terminal on your local insect folder and then run npm link ../path-to-test-project/node_modules/react. This will make insect use the copy of react from your local test project. Now you can test your changes.
  11. After all is done, push to your forked repository and then send a pull request.


⚖️ Licence

MIT (c) Collins Enebeli.

You might also like...

Pretty, customisable, cross browser replacement scrollbars

jScrollPane - cross browser custom scroll bars jScrollPane is a jQuery plugin which allows you to replace a browser's default scroll bars (on an eleme

Dec 15, 2022

Customisable javascript skeleton loader.

Customisable javascript skeleton loader.

JS Skeleton loader Simple but very powerful loader package built with full javascript. Installation To install this package, include index.js file int

Dec 1, 2022

Horizontal Timeline 2.0, a fully customisable jQuery plugin to create a dynamic timeline on the horizontal axis.

Horizontal Timeline 2.0 by yCodeTech Twitter @yCodeTech Current Version: 2.0.5.3 Quick Links: Setup | Options | Autoplay | Known Issues | Known Issues

May 29, 2022

Purple hats Desktop is a customisable, automated web accessibility testing tool that allows software development teams to find and fix accessibility problems to improve persons with disabilities (PWDs) access to digital services.

Purple hats Desktop is a customisable, automated web accessibility testing tool that allows software development teams to find and fix accessibility problems to improve persons with disabilities (PWDs) access to digital services.

Purple HATS Desktop Purple hats Desktop is a desktop frontend for Purple HATS accessibility site scanner - a customisable, automated web accessibility

May 11, 2023

This web application is a type of a scoreboard showing the names and current scores of the leading competitors in any field which is using API's to get and set data

This web application is a type of a scoreboard showing the names and current scores of the leading competitors in any field which is using API's to get and set data

Leaderboard-project This web application is a type of a scoreboard showing the names and current scores of the leading competitors in any field which

Feb 11, 2022

A plugin for Strapi that provides the ability to auto slugify a field for any content type

strapi-plugin-slugify A plugin for Strapi that provides the ability to auto slugify a field for any content type. It also provides a findOne by slug e

Nov 28, 2022

Service Installer for VMware Tanzu is a one-click automation solution that enables VMware field engineers to easily and rapidly install, configure, and operate VMware Tanzu services across a variety of cloud infrastructures.

Service Installer for VMware Tanzu Service Installer for VMware Tanzu seeks to provide a one-click automation solution to enable our VMware engineers

Dec 1, 2022

Email Genie Allows autocomplete on email field by providing a list of domain suggestions (gmail.com, outlook.com, etc.).

Email Genie  Allows autocomplete on email field by providing a list of domain suggestions (gmail.com, outlook.com, etc.).

Allows users to easily and quickly complete an email field by providing a list of domain suggestions (gmail.com, outlook.com, etc.). This package stands out for its flexibility, its compatibility with libraries / frameworks, but especially its use of basic HTML and Javascript functionalities that maximize the native behavior of desktop AND mobile browsers.

Oct 4, 2022

A jquery plugin to determine when a user has stopped typing in a text field.

The official home for the TypeWatch jQuery plugin. TypeWatch calls a function when a user has typed text in an input, textarea and changes in div from

Nov 3, 2022
Comments
A fast, vanilla JS customisable select box/text input plugin for modern browsers ⚡

choices A fast, vanilla, lightweight (~16kb gzipped ?? ), configurable select plugin for modern browsers. Similar to Select2 and Selectize but without

null 9 Aug 9, 2022
A JavaScript library allows showing/hiding "dependent" field(s) if the value of the “dependee” field matches the right condition.

MF Conditional Fields A JavaScript library that show/hide form elements based on the value of one field or many. Advantages Lightweight & fast. Comes

Ali Khallad 11 Aug 11, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A Jquery plugin that allows user to enter multiple emails using one input field

multi-emails A Jquery plugin that allows user to enter multiple emails using one input field Usage $("...").multiEmails() Options color textColor font

null 1 Aug 26, 2022
VanillaSelectBox - A dropdown menu with lots of features that takes a select tag and transforms it into a single or multi-select menu with 1 or 2 levels

vanillaSelectBox v1.0.0 vanillaSelectBox : v1.00 : Adding a package.json file New : Possibility to change the dropdown tree and change the remote sear

philippe MEYER 103 Dec 16, 2022
Bootstrap 5 spinner/loading/pending indicator for ,