ctify

Text fields

Text fields let users enter text into a UI

Usage

Props

TextField

NameTypeDefaultDescription
labelstring—Input label
isInvalidboolean—Whether the value is invalid.
isDisabledboolean—Whether the input is disabled.
isReadOnlyboolean—Whether the input can be selected but not changed by the user.
isRequiredboolean—Whether user input is required on the input before form submission.
validate(value: string) => ValidationError | true | null | undefined—A 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.
autoFocusboolean—Whether the element should receive focus on render.
valuestring—The current value (controlled).
defaultValuestring—The default value (uncontrolled).
autoCompletestring—Describes the type of autocomplete functionality the input should provide if any. See MDN.
maxLengthnumber—The maximum number of characters supported by the input. See MDN.
minLengthnumber—The minimum number of characters required by the input. See MDN.
patternstring—Regex 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 search—Hints at the type of data that might be entered by the user while editing the element or its contents. See MDN.
namestring—The 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.ReactNode—The children of the component. A function may be provided to alter the children based on component state.
classNamestring—The CSS className for the element. A function may be provided to compute the class based on component state.
styleReact.CSSProperties—The 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.