Skip to content

Input

Input component for entering content via mouse or keyboard, the most basic form control.

Quick Start

Basic Usage

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

API Reference

Properties

PropertyTypeDefaultDescription
labelstring''Input label for Material Design style experience
placeholderstring''Placeholder text
valuestring''Input value
disabledbooleanfalseWhether the input is disabled
typestring'text'Input type: text, password, number
iconstring''Input icon
namestring''Form field name for form submission
statusstring''Input status: error, warning
minnumber-Minimum value for number input
maxnumber-Maximum value for number input
stepnumber1Step value for number input

Label Input label

Provides Material Design style input experience

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

Placeholder placeholder

Consistent with native placeholder attribute

html
<r-input placeholder="Enter username"></r-input>

Disabled State disabled

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

Input Value value

html
<r-input value="1234"></r-input>

Icon icon

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

Input Types type

Password Input

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

Number Input

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

Form Field Name name

html
<r-input name="username" label="Username"></r-input>

Status status

Error State

html
<r-input status="error" label="Username"></r-input>

Warning State

html
<r-input status="warning" label="Username"></r-input>

Events

Change Event onchange

html
<r-input onchange="handleChange(this.value)" label="Username"></r-input>
javascript
const input = document.createElement('r-input');
input.setAttribute('label', 'Username');
const handleChange = (value) => {
  console.log('Value changed:', value);
};
input.addEventListener('change', handleChange);

Input Event oninput

javascript
const input = document.createElement('r-input');
input.setAttribute('label', 'Username');
const handleInput = (value) => {
  console.log('Typing:', value);
};
input.addEventListener('input', handleInput);

Best Practices

  • Labels: Add meaningful labels to inputs
  • Placeholders: Use placeholders for input hints
  • Icons: Add relevant icons to enhance UX
  • Validation: Use status property to show input state
  • Types: Choose appropriate input types for content

Released under the MIT License.