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:

<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>

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
valuestringControlled value
onChange(value: string) => voidFires on committed change
onInput(value: string) => voidFires on every keystroke
onDebouncedInput(value: string) => voidFires after debounce ms of inactivity
onClear() => voidFires when the clear button is clicked
debouncenumberDebounce 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.)
namestringForm field name
requiredbooleanfalseMarks field as required
patternstringNative validation pattern
inputModestringVirtual keyboard hint (numeric, email, etc.)
autoCompletestringBrowser autocomplete hint
minlengthnumberMinimum character length
maxlengthnumberMaximum character length
minstring | numberMinimum value (for type="number")
maxstring | numberMaximum value (for type="number")
stepstring | numberStep increment (for type="number")
spellCheckbooleanEnable/disable browser spell check
placeholderstringPlaceholder text
labelstringVisible label rendered by the web component
descriptionstringHelper 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' | stringCustom border-radius override
colorstringCustom 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.