How to style Placeholder Text in React Native (Tcomb Form Native) - react-native

I am using Tcomb Form Native for forms and putting auto tag for placeholder in the options. However I would like to change the style for the text displayed. Is it possible to change that ?
var options = {
auto: 'placeholders',
};

<TextInput/> takes a prop of placeholderTextColor additionally the placeholder text should inherit whatever styles you put on the TextInput see the following example here: https://rnplay.org/apps/Yyfuag

Related

Why it shows box inside a box when add multiline in react mui textfield and how to remove the inner box

I want to create a textfield using react mui textfield. But when I add the multiline prop it gives two boxes with border. how to remove the inner box margin
I tried several css and styling options but didn't work
The issue you're encountering is likely due to the default styling of the TextField component in Material-UI.
One solution to remove the inner margin of the TextField is to use the sx prop to override the default styles.
Documentation on how to use sx prop: https://mui.com/system/getting-started/the-sx-prop/
Example below:
<TextField
multiline
sx={{ p: 0, m: 0 }}
/>

how numberOfLines work in react native Text component?

as the doc says: ellipsizemode props defines how text will be truncated. in my case, i want to show a expand button instead of ellipsis glyph, and i could expand the text to show all of them by press the button.
so i want to figure out how numberOfLines actually works in Text component in react-native. then i could archive this, anyone could help?
It will show your content in <Text> component which is fitted in those numberOfLines.
With output you are expecting or want to perform, you can use dynamic numberOfLines using state.
Just have that state variable default value of lineNumbers and change it when pressing on button or any other component.
this.state = {
lineNumbers: 2
}
This indicates your numberOfLines will be default 2, and once user press on button or read more
this.setState({lineNumbers: null})
It will show whole content.
<Text numberOfLines={this.state.lineNumbers}>

React Native: Why long text is not shown under Text component?

Need to show the long text, which is retrieved from server.
I'm using web storm and react native 0.57
<Text>{this.state.responseText}</Text>
Should be able to view long text under the text tag. Why long text is not shown under Text component?
Yes, I was also facing same problem. Use WebView instead of text component.
<WebView
originWhitelist={['*']}
source={{html: this.state.responseText}}}
/>
I think you should use numberOfLine = {} property of text component.
you can edit style of your text component and make fontsize larger
<Text style={{fontSize: 40}}>{this.state.responseText}</Text>

Force focus ReactNative TextInput

I'm having trouble force focussing a react native TextInput field.
It's focused when the page loads with autofocus={true}.
But after blurring I would need to press the text input field, but that's hidden because of design reasons. Is there a way to document.getElementById("myText").focus(); in react native that I can call after onBlur()?
Cheers.
You need to assign the TextInput field to a ref like this:
<TextInput ref={ref => (this.ref = ref)} />
Then you can programmatically focus it by running focus() on it, like so:
this.ref.focus();
Here's a little Snack where I run the focus/blur function when pressing a button:
https://snack.expo.io/#marcelkalveram/auto-focus-input-field-using-ref
It should be easy to replicate this for your navigation scenario.
In case you're using react-navigation, this is the part of the docs you'll be interested in: https://reactnavigation.org/docs/en/navigation-prop.html#addlistener-subscribe-to-updates-to-navigation-lifecycle

react native mask input when using react-native-paper (material design)

I am using the InputText component from react-native-paper. How do I add input masking without having to use another library? In the image below, I want to add an input mask for the mobile number, but I don't know how to do it without using another library, and if I use another library, then I won't have the material design input style. Please help.
Screenshot
You can use react-native-mask-input or any other mark library with react-native-paper. You can use render prop of Text Input to pass react-native-mask-input component such that
<TextInput
label="Phone number"
render={props =>
<TextInputMask
{...props}
mask="+[00] [000] [000] [000]"
/>
}
/>
Refer render of TextInput
HTH