ctify

Text fields

Text fields let users enter text into a UI

Usage

Props

TextField

NameTypeDefaultDescription
labelstringInput label
isInvalidbooleanWhether the value is invalid.
isDisabledbooleanWhether the input is disabled.
isReadOnlybooleanWhether the input can be selected but not changed by the user.
isRequiredbooleanWhether user input is required on the input before form submission.
validate(value: string) => ValidationError | true | null | undefinedA function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.
autoFocusbooleanWhether the element should receive focus on render.
valuestringThe current value (controlled).
defaultValuestringThe default value (uncontrolled).
autoCompletestringDescribes the type of autocomplete functionality the input should provide if any. See MDN.
maxLengthnumberThe maximum number of characters supported by the input. See MDN.
minLengthnumberThe minimum number of characters required by the input. See MDN.
patternstringRegex pattern that the value of the input must match to be valid. See MDN.
typetext textarea search url tel email password string & {}'text'The type of input to render. See MDN.
inputModenone text tel url email numeric decimal searchHints at the type of data that might be entered by the user while editing the element or its contents. See MDN.
namestringThe name of the input element, used when submitting an HTML form. See MDN.
validationBehaviornative aria'native'Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.
childrenReact.ReactNodeThe children of the component. A function may be provided to alter the children based on component state.
classNamestringThe CSS className for the element. A function may be provided to compute the class based on component state.
styleReact.CSSPropertiesThe inline style for the element. A function may be provided to compute the style based on component state.
variantfilled outlined'filled'
suffixTextstring
prefixTextstring
leadingIconReact.ReactNode
trailingIconReact.ReactNode

Events

NameTypeDescription
onFocus(e: FocusEvent<T>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<T>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
onChange(value: T) => voidHandler that is called when the value changes.
onCopyClipboardEventHandler<HTMLInputElement>Handler that is called when the user copies text. See MDN.
onPasteClipboardEventHandler<HTMLInputElement>Handler that is called when the user pastes text. See MDN.
onCompositionStartCompositionEventHandler<HTMLInputElement>Handler that is called when a text composition system starts a new text composition session. See MDN.
onSelectReactEventHandler<HTMLInputElement>Handler that is called when text in the input is selected. See MDN.
onBeforeInputFormEventHandler<HTMLInputElement>Handler that is called when the input value is about to be modified. See MDN.
onInputFormEventHandler<HTMLInputElement>Handler that is called when the input value is modified. See MDN.