Skip to main content

Field

danger

This SDK is a Work In Progress! All features are subject to change.

A field represents a text input element in a form. It supports properties like name, label, and event handlers (onChange, onBlur, onFocus).

Field

Usage

import { Field } from "@tiendanube/nube-sdk-jsx";

<Field
name="email"
label="Email"
onChange={() => {}}
onBlur={() => {}}
onFocus={() => {}}
/>;

Properties

PropertyTypeRequiredDescription
namestringYesThe name of the field, used to identify it in forms.
labelstringYesThe label text displayed above the field.
valuestringNoThe current value of the field input.
maskstringNoFormat mask for the field input (e.g., "000.000.000-00" for CPF).
styleStyleSheetNoCustom styles for the field.
autoFocusbooleanNoWhether the field should automatically receive focus when mounted.
onChangeNubeComponentFieldEventHandlerNoFunction called when the field value changes.
onBlurNubeComponentFieldEventHandlerNoFunction called when the field loses focus.
onFocusNubeComponentFieldEventHandlerNoFunction called when the field receives focus.

Event Handlers

The field component supports three event handlers that receive an object with the following properties:

onChange: (data: {
type: "change"; // The type of event
state: NubeSDKState; // The current state of the SDK
value?: string; // The new value of the field
}) => void

onBlur: (data: {
type: "blur"; // The type of event
state: NubeSDKState; // The current state of the SDK
value?: string; // The current value of the field
}) => void

onFocus: (data: {
type: "focus"; // The type of event
state: NubeSDKState; // The current state of the SDK
value?: string; // The current value of the field
}) => void