Skip to main content
Version: Next

Input

import { Input } from '@editora/ui-react';

Composition Pattern​

Input follows a composition pattern. Use Input.Prefix, Input.Suffix, and Input.Error as named sub-components to compose the field layout declaratively:

Live Editor
function InputDemo() {
  return (
    <ThemeProvider>
      <Input
        label="Email"
        type="email"
        placeholder="name@company.com"
        required
        clearable
        validation="error"
        onChange={(value) => console.log(value)}
      >
        <Input.Prefix>✉️</Input.Prefix>
        <Input.Suffix>
          <button type="button">Verify</button>
        </Input.Suffix>
        <Input.Error>Enter a valid email address</Input.Error>
      </Input>
    </ThemeProvider>
  );
}
Result
Loading...

Sub-components​

Sub-componentSlotDescription
Input.PrefixprefixContent rendered on the left side of the input
Input.SuffixsuffixContent rendered on the right side of the input
Input.ErrorerrorError message shown when validation="error"

Props​

PropTypeDefaultDescription
valuestring—Controlled value
onChange(value: string) => void—Fires on committed change
onInput(value: string) => void—Fires on every keystroke
onDebouncedInput(value: string) => void—Fires after debounce ms of inactivity
onClear() => void—Fires when the clear button is clicked
debouncenumber—Debounce delay in ms for onDebouncedInput
clearablebooleanfalseShows a clear button when the field has a value
validation'error' | 'success' | 'none''none'Visual validation state
counterbooleanfalseShows character count (requires maxlength)
typestring'text'Native input type (email, password, number, etc.)
namestring—Form field name
requiredbooleanfalseMarks field as required
patternstring—Native validation pattern
inputModestring—Virtual keyboard hint (numeric, email, etc.)
autoCompletestring—Browser autocomplete hint
minlengthnumber—Minimum character length
maxlengthnumber—Maximum character length
minstring | number—Minimum value (for type="number")
maxstring | number—Maximum value (for type="number")
stepstring | number—Step increment (for type="number")
spellCheckboolean—Enable/disable browser spell check
placeholderstring—Placeholder text
labelstring—Visible label rendered by the web component
descriptionstring—Helper text below the field
readOnlybooleanfalseMakes the field read-only
autofocusbooleanfalseFocuses the field on mount
disabledbooleanfalseDisables the field
size'sm' | 'md' | 'lg' | '1' | '2' | '3''md'Input size
variant'classic'Visual style
tone'default'Color tone
density'default' | 'compact' | 'comfortable''default'Vertical spacing
shape'default' | 'square' | 'soft''default'Border-radius preset
radius'none' | 'large' | 'full' | string—Custom border-radius override
colorstring—Custom color token
floatingLabelbooleanfalseAnimates label above the field on focus/fill
headlessbooleanfalseStrips all default styles

Examples​

Search with prefix and debounce​

<Input
placeholder="Search..."
debounce={300}
onDebouncedInput={(value) => fetchResults(value)}
>
<Input.Prefix>🔍</Input.Prefix>
</Input>

Character counter​

<Input label="Bio" maxlength={160} counter />

Number input with constraints​

<Input type="number" min={0} max={100} step={5} label="Score" />

Validation with error message​

<Input label="Username" validation="error">
<Input.Error>Username is already taken</Input.Error>
</Input>

Notes​

  • Input.Error is only visible when validation="error" is set on the root.
  • counter requires maxlength to display the limit.
  • minlength / maxlength and autofocus map directly to the underlying <ui-input> web component attributes.