Skip to content

Commit b445a52

Browse files
authored
TextField - Adding 'errorColor' prop to allow customizing the error massage text color. (#915)
1 parent bea887b commit b445a52

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

demo/src/screens/componentScreens/TextFieldScreen/InputsScreen.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ export default class InputsScreen extends Component {
155155
placeholder="Underline colors & error"
156156
onChangeText={this.onChangeText}
157157
error={this.state.error}
158-
underlineColor={{focus: Colors.purple50, error: Colors.yellow60}}
158+
underlineColor={{focus: Colors.purple50, error: Colors.orange60}}
159+
errorColor={Colors.orange60}
159160
/>
160161

161162
<TextField

src/components/textField/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ export default class TextField extends BaseInput {
9898
* should the input component support error messages
9999
*/
100100
enableErrors: PropTypes.bool,
101+
/**
102+
* input error message's text color
103+
*/
104+
errorColor: PropTypes.string,
101105
/**
102106
* should the input expand to another text area modal
103107
*/
@@ -475,14 +479,15 @@ export default class TextField extends BaseInput {
475479
}
476480

477481
renderError(visible) {
478-
const {enableErrors, useTopErrors} = this.getThemeProps();
482+
const {enableErrors, useTopErrors, errorColor} = this.getThemeProps();
483+
const textColor = errorColor ? {color: errorColor} : undefined;
479484
const positionStyle = useTopErrors ? this.styles.topLabel : this.styles.bottomLabel;
480485
const error = this.getErrorMessage();
481486

482487
if (visible && enableErrors) {
483488
return (
484489
<Text
485-
style={[this.styles.errorMessage, this.styles.label, positionStyle]}
490+
style={[this.styles.errorMessage, this.styles.label, positionStyle, textColor]}
486491
accessible={!_.isEmpty(error) && !useTopErrors}
487492
>
488493
{error}

0 commit comments

Comments
 (0)