Skip to content

Input

Entering content via mouse or keyboard is the most basic form field packaging.

Code demo

Input field:
xml
<r-input></r-input>

Attribute

label

Provide an input experience similar to Metiral Design.

html
<r-input label="user"></r-input>

placeholder

Consistent with native 'placeholder'.

html
<r-input placeholder="user"></r-input>

disabled

The input box can be disabled by disabled. After disabled, the events on the button become invalid.

html
<r-input label="user" disabled></r-input>

value

Sets or returns the value of the 'value' property of the input box.

type

Currently support 'password', 'number' these types, set will appear additional 'ui' controls.

Password entry field

The password can be switched between plain text and ciphertext.

html
<r-input icon="lock" type="password"></r-input>

icon

You can set an 'icon' to represent the tag identifier.

html
<r-input icon="user"></r-input>

Digital input box

Numeric input box, similar to the native 'input[type=number]', support 'min', 'max', 'step' attributes, support keyboard up and down keys to switch numbers.

html
<r-input type="number" min="-10" max="10" step="0.5"></r-input>

name

Valid when associated with the form component, the field name collected when the form is submitted

status

  • error

Default color value: #ff4d4f

xml
<r-input status="error"></r-input>
  • warning

Default color value:#ff7875

xml
<r-input  status="warning"></r-input>

event

Common callback events.

onchange

Triggered when text changes.

html
<r-input onchange="func(this.value)"></r-input>
js
const input = document.createElement('r-input');
input.setAttribute('label', 'home');
const func = (e) => {
  console.log(e);
};
input.addEventListener('change', func);

oninput

Triggered when text changes.

js
const input = document.createElement('r-input');
input.setAttribute('label', 'home');
const func = (e) => {
  console.log(e);
};
input.addEventListener('input', func);

The e parameter structure of the event

input method

Released under the MIT License.