Support for style-related props (not set via 'style') in React Native
See original GitHub issuePresently in styled components, there is no way to affect other style-related props in React Native.
This style-related-prop-not-defined-via-style
can be found in many third party libraries (such as React Native Navbar’s tintColor
prop), in custom components one might write themselves, and in React Native’s core components, for example:
- TouchableHighlight underlayColor
- ActivityIndicator color and size
- Slider maximumTrackTintColor and minimumTrackTintColor
- StatusBar backgroundColor
- TextInput placeholderTextColor, underlineColorAndroid and keyboardAppearance
- Switch onTintColor, thumbTintColor and tintColor
- … and a lot more
It’s of course possible to simply set these props manually, but styled-component’s themes are unable to be leveraged to standardize them across the codebase.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Is it possible to use styled-theming to customize ...
I'm using React-Native and i want to change the color prop of an ActivityIndicator according to the defined theme style. Is it possible...
Read more >Style
With React Native, you style your application using JavaScript. All of the core components accept a prop named style. The style names and ......
Read more >Layout Props
More detailed examples about those properties can be found on the Layout with Flexbox page. ... Ems and other units are not supported....
Read more >Image Style Props
Style BorderWidth and BorderColor Function Component Example ... This is useful in cases which are not supported by the Android ...
Read more >Props
You can put any JavaScript expression inside braces in JSX. Your own components can also use props . This lets you make a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is now finally possible in version two with the
.attrs
constructor!That’s an unnecessary escape hatch @adamterlson, since you can already set any prop desired when rendering. I think with the list @irakli-janiashvili dug up we should be fine to publish a first version with support for these. It doesn’t matter if it’s not 100% complete, as we can always add more to the list.
Basically, what we should do is have a separate module called
react-native-style-props
which exports an object. This object should be keyed by primitive and each one should have an array of props like this maybe?Then from
styled-components
we can check at creation time if the current property is supported as aprop
, and pass it to the underlying primitive. What do you think, does somebody want to go ahead and create that repo?