# TextField
Use a text field to allow merchants to enter or edit text. If you want to specify the kind of input, then use a formatted text field.
```tsx
import React, {useState} from 'react';
import {
TextField,
Screen,
ScrollView,
Navigator,
reactExtension,
Text,
} from '@shopify/ui-extensions-react/point-of-sale';
const SmartGridModal = () => {
const [name, setName] = useState('');
return (
{name ? `Hello ${name}!` : ''}
);
};
export default reactExtension('pos.home.modal.render', () => (
));
```
```ts
import {
Navigator,
Screen,
ScrollView,
Text,
TextField,
extension,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const textField = root.createComponent(TextField, {
label: 'Name',
placeholder: 'Input your name here',
required: true,
value: '',
});
const textBox = root.createComponent(Text);
const onChangeHandler = (newValue: string) => {
textField.updateProps({value: newValue});
const greeting = newValue ? `Hello ${newValue}!` : '';
textBox.replaceChildren(greeting);
};
textField.updateProps({onChange: onChangeHandler});
const scrollView = root.createComponent(ScrollView);
scrollView.append(textField);
scrollView.append(textBox);
const screen = root.createComponent(Screen, {
name: 'TextField',
title: 'Text Field Example',
});
screen.append(scrollView);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
});
```
## TextField
Use a text field to allow merchants to input or modify multiline text.
### NewTextFieldProps
### action
value: `InputAction`
- InputAction: export interface InputAction {
/**
* The text displayed in the button.
*/
label: string;
/**
* A callback to be performed.
*/
onPress: () => void;
/**
* Whether the button can be pressed.
*/
disabled?: boolean;
}
A button under the text field to provide extra functionality.
### disabled
value: `boolean`
Whether the field can be modified.
### error
value: `string`
Indicates an error to the user. The field is given specific stylistic treatment to communicate problems that have to be resolved immediately.
### helpText
value: `string`
The label under the text field which provides guidance or instructions that assist users.
### label
value: `string`
The content to use as the field label.
### maxLength
value: `number`
The maximum number of characters allowed in the input field.
### onBlur
value: `() => void`
The callback when focus is removed.
### onChange
value: `(value: string) => void`
The callback when the user has finished editing a field.
### onFocus
value: `() => void`
The callback when input is focused.
### onInput
value: `(value: string) => void`
Callback when the user makes any changes in the field. As noted in the documentation for `onChange`, you **must not** use this to update `value` — use the `onChange` callback for that purpose. Use the `onInput` prop when you need to do something as soon as the user makes a change, like clearing validation errors that apply to the field as soon as the user begins making the necessary adjustments.
### placeholder
value: `string`
A short hint that describes the expected value of the field.
### required
value: `boolean`
Whether the field needs a value.
### value
value: `string`
The current value for the field. Defaults to now. You should update this value in response to the `onChange` callback.
### InputAction
### disabled
value: `boolean`
Whether the button can be pressed.
### label
value: `string`
The text displayed in the button.
### onPress
value: `() => void`
A callback to be performed.