Fluxo UIFluxo UIv0.4.1

TextInput

A flexible text input component with support for labels, validation, and various states.

Basic Usage

Basic Text Input

Basic Example
import { TextInput } from 'fluxo-ui';

function MyComponent() {
  const [value, setValue] = useState('');

  return (
    <TextInput
      placeholder="Enter some text..."
      value={value}
      onChange={(e) => setValue(e.target.value)}
    />
  );
}

With Label

Text Input with Label

<TextInput
  label="Full Name"
  placeholder="John Doe"
/>

With Icons

Text Input with Icons

🔍
<TextInput
  label="Search"
  placeholder="Search..."
  rightIcon={<span>🔍</span>}
  value={value}
  onChange={(e) => setValue(e.value)}
/>
<TextInput
  label="Email"
  placeholder="user@example.com"
  leftIcon={<span></span>}
  value={value}
  onChange={(e) => setValue(e.value)}
/>

States

Input States

<TextInput label="Normal" placeholder="Normal state" value={value} onChange={(e) => setValue(e.value)} />
<TextInput label="Disabled" placeholder="Disabled state" value={value} onChange={(e) => setValue(e.value)} disabled />
<TextInput label="Read Only" value="Read only value" readonly onChange={(e) => setValue(e.value)} />
<TextInput label="Required" placeholder="Required field" value={value} onChange={(e) => setValue(e.value)} required />

Validation

Input with Validation

const [value, setValue] = useState('');
const [error, setError] = useState('');

const handleChange = (e) => {
  const newValue = e.target.value;
  setValue(newValue);

  if (newValue.length < 3 && newValue.length > 0) {
    setError('Must be at least 3 characters');
  } else {
    setError('');
  }
};

<TextInput
  label="Username"
  placeholder="Enter username"
  value={value}
  onChange={handleChange}
  error={error}
/>

Import

import { TextInput } from 'fluxo-ui';

Props

value
string

Current value of the input (controlled)

placeholder
string

Placeholder text

label
string

Label text

error
string | boolean

Error message string (also marks field invalid). Pass `true` to mark invalid without a message

invalid
boolean

Force the field into an invalid state without an error message

helperText
ReactNode

Helper text rendered under the input and linked via aria-describedby

clearable
boolean"false"

Show an X button to clear the input value

onClear
() => void

Callback fired after the value is cleared via the clear button

disabled
booleanfalse

Disable the input

readonly
booleanfalse

Make the input read-only

required
booleanfalse

Mark the input as required

autoFocus
booleanfalse

Auto focus the input on mount

maxLength
number

Maximum character limit

minLength
number

Minimum character requirement

pattern
string

Regex pattern for validation

autoComplete
string

Auto-complete hint

leftIcon
ReactNode

Icon to display on the left side

rightIcon
ReactNode

Icon to display on the right side

id
string

Unique identifier for the input

name
string

Name attribute for the input

onChange
function

Change event handler

className
string

Additional CSS classes

Features

Controlled Input

Fully controlled via value and onChange for form state management

Icon Slots

Left and right icon slots accept any React node

Validation

Error prop displays inline validation messages below the input

States

Disabled, read-only, required, and error states fully supported

Character Limits

maxLength and minLength props for length constraints

Accessibility

Label association, ARIA attributes, and keyboard focus support

Theming

Full dark/light + 5 brand themes via CSS variables — zero extra config