All Projects → rumkin → mighty-input

rumkin / mighty-input

Licence: MIT license
Text input for modern web

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mighty-input

react-ratings-declarative
A customizable rating component for selecting x widgets or visualizing x widgets
Stars: ✭ 41 (+105%)
Mutual labels:  input, react-component
React Telephone Input
React component for entering and validating international telephone numbers
Stars: ✭ 254 (+1170%)
Mutual labels:  input, react-component
react-star-ratings
A customizable svg star rating component for selecting x stars or visualizing x stars
Stars: ✭ 128 (+540%)
Mutual labels:  input, react-component
React Currency Input Field
React component for an input field
Stars: ✭ 111 (+455%)
Mutual labels:  input, react-component
React Intl Tel Input
Rewrite International Telephone Input in React.js. (Looking for maintainers, and PRs & contributors are also welcomed!)
Stars: ✭ 212 (+960%)
Mutual labels:  input, react-component
React Code Input
React component for entering and validating PIN code.
Stars: ✭ 207 (+935%)
Mutual labels:  input, react-component
Tagify
🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue
Stars: ✭ 2,305 (+11425%)
Mutual labels:  input, react-component
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (+65%)
Mutual labels:  input, react-component
react-simple-range
🔉 React slider component for inputting a numeric value within a range.
Stars: ✭ 20 (+0%)
Mutual labels:  input, react-component
angular-code-input
Code (number/chars/otp/password) input component for angular 7, 8, 9, 10, 11, 12+ projects including Ionic 4, 5 +
Stars: ✭ 112 (+460%)
Mutual labels:  input
react-carousel-minimal
React.js Responsive Minimal Carousel
Stars: ✭ 76 (+280%)
Mutual labels:  react-component
react-compare-slider
A slider component to compare any two React components in landscape or portrait orientation. It supports custom images, videos... and everything else.
Stars: ✭ 78 (+290%)
Mutual labels:  react-component
dynamic-input-fields-reactjs
Example of the dynamic input fields in ReactJS
Stars: ✭ 31 (+55%)
Mutual labels:  input
rawtx
A Golang module that helps you answer questions about raw Bitcoin transactions, their inputs, outputs and scripts.
Stars: ✭ 12 (-40%)
Mutual labels:  input
file-upload-with-preview
🖼 Simple file-upload utility that shows a preview of the uploaded image. Written in TypeScript. No dependencies. Works well with or without a framework.
Stars: ✭ 406 (+1930%)
Mutual labels:  input
markdown-navbar
Best markdown navigation bar for React.
Stars: ✭ 122 (+510%)
Mutual labels:  react-component
hookahjs
Add empty/dirty/touched CSS hooks to input and textarea elements automatically (1056 bytes)
Stars: ✭ 21 (+5%)
Mutual labels:  input
win95-media-player
💿 Back from 1995, and running on your website
Stars: ✭ 56 (+180%)
Mutual labels:  react-component
react-native-nested-listview
A UI component for React Native for representing nested arrays of N levels
Stars: ✭ 163 (+715%)
Mutual labels:  react-component
react-fake-component
Chuck Norris faking components
Stars: ✭ 24 (+20%)
Mutual labels:  react-component

Mighty Input

Tiny React text input component for the modern web. Use HTML to decorate <input /> value for your goals.

Mighty input example GIF

👇 Source of the preview 👆

function AnimatedInput({ value, ...props }) {
  const render = nextValue => Array.from(nextValue)
  .map((char, i) => (
    <span key={i} className={`animation-${getCharType(char)}`}>
      {char}
    </span>
  ));

  return (
    <MightyInput value={value} render={render} {...props}/>
  );
}

function getCharType(char, index) {
  switch (char) {
    case "😀": // Smiley face emoji
      return "smiley";
    case "💗": // Heart emoji
      return "heart";
    default:
      return "char";
  }
}

CSS could be found in examples folder.

Installation

npm i mighty-input

Live examples

Usage

Use render property to specify custom render method and receive changed via onUpdate property callback.

<MightyInput
  render={(value) => (
    <span style={{borderBottom: '2px solid green'}}>
      {value}
    </span>
  )}}
  onUpdate={(value) => {
    // Value changed
  }}
/>

Filter value

Use filter prop to specify input filter function.

Filtrate any non-digit values:

<MightyInput
  filter={(next, prev) => {
    if (/^\d$/.test(next)) {
      return next;
    }
    else {
      return prev;
    }
  }}
/>

API

render()

(next:string, previous:string) -> string|React.Element

Render property is a function to transform value to HTML or another string. This function receives next and previous values of input field.

<MightyInput render={
  (next) => <span style={{color: 'red'}}>{next}</span>
} />

filter()

(next:string, previous:string) -> string

Filter property is a function to filtrate input and return new output value. This function receives next and previous values of input field.

<MightyInput filter={
  (next, prev) => next.length < 10 ? next : prev
} />

onUpdate()

(next:string, previous:string) -> void

Update event handler. It emits each time value (passed through filter) changes.

modifiers{}

{
  focus:string = '--focus',
}

Modifers property is an object with CSS classes for different states. It's using to simulate native CSS behavior for input wrapper. Currently it only has one option: focus.

References

MightyInput is inspired by Colin Kuebler's LDT.

License

MIT © Rumkin

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].