A great css input and textarea input effect

A great css input and textarea input effect

·

0 min read

Do you like Visual Studio Code as much as I do? It is really great with it.

Alt Text

One day, a good friend of mine recommended me a Visual Studio Code plugin called Power Mode. At first I didn't care, but later I accidentally installed it. Oh its effect is probably like this.

img

See it, suddenly I found it really fun. I think this must be the work of some boring genius. So I wonder if I can use CSS to simulate this effect.

So PowerModeInput was born.


PowerModeInput

https://github.com/lindelof/power-mode-input

PowerModeInput can make your text input box more compelling

Online demo


Useage

Install

npm install --save power-mode-input

Usage

import PowerModeInput from "power-mode-input";

const input = document.getElementById("obinput");
PowerModeInput.make(input);

// close PowerModeInput
PowerModeInput.close(input);

// destroy PowerModeInput
PowerModeInput.destroy();

// another usage
PowerModeInput.make(".phone", {
  height: 5,
  tha: [0, 360],
  g: 0.5,
  num: 5,
  radius: 6,
  circle: true,
  alpha: [0.75, 0.1],
  color: "random"
});

If you are in react, you can use it like this

componentDidMount(){
  PowerModeInput.make(this.inputRef.current);
}

You can use it like this in vue.js

mounted() {
  PowerModeInput.make(this.$refs.inputRef);
}

Of course this can be done in angular

const inputElement = this.elementRef.nativeElement.querySelector('input');
PowerModeInput.make(inputElement);

Parameter Description

PowerModeInput.make(input, {
  height: 5,
  tha: [0, 360],
  g: 0.5,
  num: 5,
  ... // Parameter
});
keydescribetypeexample
gWhether to add gravitynumber1
numThe number of particles emitted each timenumber3
radiusThe radius of every particlenumber10
alphaThe alpha of every particlenumber.1
thaThe Particle emitter anglearray[0, 360]
vThe Particle emitter Particle velocitynumber0.5
lifeThe life of every particlenumber1.2
colorParticle colorarray or string#ffcccc
randomRandom forcenumber1.2
yParticle emitter heightnumber2
heightParticle emitter height Ibidnumber2

Develop process

Of course, the development process is not easy. At first I thought it was very easy to get the input box cursor. Well, I found out that I was wrong. I checked a lot of articles to find a good way.

If you don’t dislike it, I also want to recommend another good library. https://github.com/lindelof/react-mouse-particles. Because most of the code for power-mode-input comes from this.

I bet anyone can use it because it is very simple. If you like this project welcome star it