Use a formatted text field when you require additional functionality such as the text field input type or a custom validator.
import React, {useState} from 'react';
import {
Navigator,
Screen,
Text,
ScrollView,
FormattedTextField,
reactExtension,
} from '@shopify/ui-extensions-react/point-of-sale';
const SmartGridModal = () => {
const [textFieldValue, setTextFieldValue] =
useState('');
return (
<Navigator>
<Screen
name="TextArea"
title="Text Area Example"
>
<ScrollView>
<FormattedTextField
placeholder="Email address"
inputType="email"
onChangeText={setTextFieldValue}
/>
<Text>{textFieldValue}</Text>
</ScrollView>
</Screen>
</Navigator>
);
};
export default reactExtension(
'pos.home.modal.render',
() => <SmartGridModal />,
);
import {
extension,
Screen,
Navigator,
ScrollView,
Text,
FormattedTextField,
} from '@shopify/ui-extensions/point-of-sale';
export default extension(
'pos.home.modal.render',
(root) => {
const homeScreen = root.createComponent(
Screen,
{
name: 'Home',
title: 'Home',
},
);
const text = root.createComponent(Text);
const textField = root.createComponent(
FormattedTextField,
{
placeholder: 'Email address',
inputType: 'email',
onChangeText: (newText) => {
text.replaceChildren(newText);
},
},
);
const scrollView =
root.createComponent(ScrollView);
homeScreen.append(scrollView);
scrollView.append(textField);
scrollView.append(text);
const navigator =
root.createComponent(Navigator);
navigator.append(homeScreen);
root.append(navigator);
},
);
Dictates when the text should be auto-capitalized.
Applies a custom validator that can dictate whether or not an entered value is valid.
Sets an error message to present to the user.
Populates the `TextField` with an text initial value.
The `InputType` of the `TextField`. This will select the appropriate keyboard.
Set whether the current value in the `TextField` is valid.
A callback that is executed every time the `TextField` value changes.
Sets a placeholder value for when the `TextField` is empty.
The title of the `TextField`.
'none' | 'sentences' | 'words' | 'characters'
Dictates what type of values can be used in a `TextField`.
'text' | 'number' | 'currency' | 'giftcard' | 'email'
Dictates what type of values can be used in a `TextField`.
'text' | 'number' | 'currency' | 'giftcard' | 'email'
'none' | 'sentences' | 'words' | 'characters'