View as Markdown

API reference: @salmonui/inputs/text-field

TextFieldcomponent

import { TextField } from '@salmonui/inputs/text-field';
function TextField(props: TextFieldProps): ReactNode;

Single-line text input: a native <input> with label, description, validation, adornments and an optional clear button. ref is the input; unknown props go to the input, className / style to the root.

Props: TextFieldProps

TextField props (19)
NameSignatureDescription
typeoptionalreadonly type?: 'text' | 'password' | 'email' | 'tel' | 'url' | 'search' | undefined;

Input type; numbers use NumberField. Default 'text'.

refoptionalreadonly ref?: Ref<HTMLInputElement> | undefined;

The native <input>.

labeloptionalinheritedlabel?: ReactNode;
descriptionoptionalinheriteddescription?: ReactNode;
errorMessageoptionalinheritederrorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | ReactNode;

Error text (or a function of the errors) shown while the field is invalid.

invalidoptionalinheritedinvalid?: boolean;

Forces the error state.

validationoptionalinheritedvalidation?: FieldValidation;

Rules in the Data Grid vocabulary.

validateOnoptionalinheritedvalidateOn?: ValidateOn;

When errors appear; default the Form's, else 'blur'.

sizeoptionalinheritedsize?: FieldSize;

Metric set. Default 'md'.

valueoptionalinheritedvalue?: string;
defaultValueoptionalinheriteddefaultValue?: string;
onValueChangeoptionalinheritedonValueChange?: ((value: string, details: TextChangeDetails) => void);
clearableoptionalinheritedclearable?: boolean;

Shows a clear button while there is a value; Escape clears too.

startAdornmentoptionalinheritedstartAdornment?: ReactNode;
endAdornmentoptionalinheritedendAdornment?: ReactNode;
localeTextoptionalinheritedlocaleText?: TextFieldLocaleText;
classNameoptionalinheritedclassName?: string;

Root class and style (the input gets every other prop).

styleoptionalinheritedstyle?: CSSProperties;
classNamesoptionalinheritedclassNames?: { readonly group?: string; readonly input?: string; readonly label?: string; readonly description?: string; readonly error?: string; };

Part classes: root is className; group, input, label, description, error.