Input

A single-line input with optional addons.

Input.Control receives a string value and onChange(value, event); use Input.LeftAddon and Input.RightAddon for addons.

Live example

Example controls

Usage

'use client';

import { Input } from '@prosazhin/pbcomponents';
import { useState } from 'react';

function Example() {
  const [value, setValue] = useState('');
  return (
    <Input>
      <Input.Control
        value={value}
        onChange={setValue}
        placeholder='Placeholder'
      />
    </Input>
  );
}

Component API

Compound parts: Input.Control, Input.LeftAddon, Input.RightAddon.

PropType / variantsPurposeDefault
size's' | 'm's · mComponent size.m
disabledbooleanDisables interaction.false
errorbooleanShows the error state.false
Input.Control.placeholderstringHint in an empty field.—
Input.Control.valuestringCurrent value of a controlled component.—
Input.Control.onChange(value: string, event: InputEvent) => voidReports the new text and input event.—
classNamestringClass of the root element.—
wrapperClassNamestringClass of the outer wrapper.—
Input.Control.typeHTML input typetext · number · email · password · url · tel · search · date · datetime-local · month · week · timeInput type: text, email, password and other native types.text
Input.Control.leftIconSvgTypenone · check · search · userIcon before the text; accepts an SVG component.—
Input.Control.rightIconSvgTypenone · check · search · userIcon after the text; accepts an SVG component.—
Input.Control.leftIconClassNamestringClass of the left icon.—
Input.Control.rightIconClassNamestringClass of the right icon.—
Input.Control.textClassNamestringClass of the text part.—

Native HTML attributes are accepted where the component renders the corresponding element. className props only affect styling.