Input

import Input from 'frui/fields/Input';
Copy

Props

Input accepts all props of a standard HTML Input element. See Moz for standard input attributes.

NameTypeRequiredNotes
classNamestringNoStandard HTML class names
defaultValuestringNoDefault value (Uncontrolled)
errorstring|booleanNoAny error message
namestringNoUsed for react server components.
onChangeFunctionNoEvent handler when value has changed
onUpdateFunctionNoUpdate event handler
passRefLegacyRefNoPasses ref to html input
styleCSS ObjectNoStandard CSS object
valuestringNoDefault value (Controlled)

Basics

Input wraps the HTML standard `<input />` element. Therefore, you can use any input attributes as props.

<Input name="name" placeholder="Enter name.." value="John Doe" />
Copy

Events

onUpdate is like onChange except the value is passed instead of the change event.

<Input onUpdate={value => alert(value)} />
Copy

On Change

The onChange event is triggered when the value has changed. The following arguments are passed to the event handler:

NameTypeSample
eventEvent Objectsee: Change Event

On Update

The onUpdate event is triggered when the value has been updated. The following arguments are passed to the event handler:

NameTypeSample
valuestring`foobar`

Errors

You can pass the error prop to highlight the input field red.

<Input error={string|true} value="Not a hotdog." />
Copy