[英]React Native Paper Text input change color
This is my React Native code using React Native Paper to generate a text input.这是我使用 React Native Paper 生成文本输入的 React Native 代码。
import * as React from 'react';
import { TextInput } from 'react-native-paper';
class MyComponent extends React.Component {
state = {
text: ''
};
render(){
return (
<TextInput
label='Email'
value={this.state.text}
onChangeText={text => this.setState({ text })}
/>
);
}
}
It will generate the following text input :它将生成以下文本输入:
How can I change the text color of "Input label" from blue to red ?如何将“输入标签”的文本颜色从蓝色更改为红色?
this is the official documentation : https://callstack.github.io/react-native-paper/1.0/text-input.html but can't seem to find a way to change the color from blue to red.这是官方文档: https : //callstack.github.io/react-native-paper/1.0/text-input.html但似乎无法找到将颜色从蓝色更改为红色的方法。
According to their documentation, you have to change the Theme .根据他们的文档,您必须更改Theme 。 If you want to replace the blue everywhere you can change the primary color here:如果你想在任何地方替换蓝色,你可以在这里更改原色:
const theme = {
...DefaultTheme,
roundness: 2,
colors: {
...DefaultTheme.colors,
primary: '#ff0000',
},
};
You should also be able to modify the color of your input only with:您还应该能够仅通过以下方式修改输入的颜色:
<TextInput theme={{ colors: { primary: #ff0000 } }}/>
i have this theme, but it does not change the color of the inputs我有这个主题,但它不会改变输入的颜色
export const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
text: '#000000',
primary: '#1cb0f6',
secondary: '#e5e5e5',
error: '#f13a59',
},
}
you can change like this:你可以这样改变:
<Input
style={styles.input}
selectionColor={theme.colors.primary}
underlineColor="transparent"
mode="outlined"
theme={{ colors: { primary: theme.colors.primary } }}
{...props}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.