TextBox
Reference
- The
TextBoxcomponent is a used to display input field with support for numeric-only input, optional decimal values, and custom styling.
Props
-
isDisabled- Type:
boolean - Description: Disables the input field if
true.
- Type:
-
numericOnly- Type:
boolean - Description: Restricts input to numeric values if
true.
- Type:
-
allowDecimal- Type:
boolean - Description: Allows decimal values if
numericOnlyistrue.
- Type:
-
value- Type:
string | number - Description: The current value of the input field.
- Type:
-
onEdit- Type:
function - Description: Callback triggered when the input value changes.
- Type:
-
onFocusOut- Type:
function - Description: Callback triggered when the input loses focus.
- Type:
-
style- Type:
object | string - Description: Custom styles or class names for the input field.
- Type:
-
placeholder- Type:
string - Description: Placeholder text for the input field.
- Type:
-
inputType- Type:
string - Default:
'text' - Description: Specifies the input type (e.g.,
text,number,password).
- Type:
Usage Example
- This renders a numeric-only input field that allows decimals and logs the edited value on change.
function Example(pageContext) {
const { protrakComponents } = React.useContext(customWidgetContext);
const { TextBox } = protrakComponents;
return(
<TextBox
numericOnly={true}
allowDecimal={true}
value="123.45"
onEdit={(val) => console.log('Edited value:', val)}
placeholder="Enter a number"
/>
);
}