View as Markdown

API reference: @salmonui/inputs/form

Fieldcomponent

import { Field } from '@salmonui/inputs/form';
function Field(props: FieldProps): ReactNode;

Label, description, error and validation around a custom control. Every Salmon field renders the same parts itself.

Props: FieldProps

Field props (18)
NameSignatureDescription
childrenreadonly children: (field: FieldRenderProps) => ReactNode;
nameoptionalreadonly name?: string | undefined;
errorPlacementoptionalreadonly errorPlacement?: 'auto' | 'manual' | undefined;

'manual' when the children render FieldError themselves. Default 'auto'.

idoptionalreadonly id?: string | undefined;

Id of the control (default from useId); the label points at it.

valueoptionalreadonly value?: unknown;

The control's current value, for validation rules.

requiredoptionalreadonly required?: boolean | undefined;
requiredMarkoptionalreadonly requiredMark?: boolean | undefined;

true marks the label while the control is required (as Form requiredMark does); false opts out under a marking Form.

disabledoptionalreadonly disabled?: boolean | undefined;
localeTextoptionalreadonly localeText?: FieldValidationText | undefined;
classNameoptionalreadonly className?: string | undefined;
styleoptionalreadonly style?: CSSProperties | undefined;
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'.