Custom Components

You can render custom components in the KendoReact Field component by using the built-in properties of the FieldRenderProps interface and any custom properties.

Using Basic Properties

You can get the Form state for the current field and trigger changes for it by using the value and onChange properties of the FieldRenderProps interface.

const MyCustomInput = (fieldRenderProps) => {
    const {label, value, onChange} = fieldRenderProps;
    return (
        <Input label={label} value={value} onChange={onChange} />
    );
};

const App = () => {
    const handleSubmit = (dataItem) => alert(JSON.stringify(dataItem, null, 2));
    return (
        <Form
            onSubmit={handleSubmit}
            render={(formRenderProps) => (
                <FormElement style={{maxWidth: 650}}>
                    <Field name={'firstName'} label={'First Name'} component={MyCustomInput} />
                    <div className="k-form-buttons">
                        <button type={'submit'} disabled={!formRenderProps.allowSubmit} className={'k-button'}>
                            Submit
                        </button>
                    </div>
                </FormElement>
            )}
        />
    );
};
ReactDOM.render(
    <App />,
    document.querySelector('my-app')
);

Setting Custom Behavior

You can display error messages and fully customize the behavior of the rendered component by using the additional properties of the Field component.

The following example demonstrates how to render a required custom checkbox a terms agreement.

Example
View Source
Edit In Stackblitz  
Change Theme:

In this article

Not finding the help you need?