2

I am using react-native-paper 3.6.0 and in their documentation, they offer to change the switch color using props.color. I have tried and:

  • iOS: OK
  • Android: The dark button is using color.background, the switch is black on black.
  • Web: The color does not have any effect

  • Read <Switch /> Source | Documentation

How can I set the color of the switch component of react-native-paper?

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
  • do you mean to set a color on android? because setting it up on web is not going to work for this react-native library. – kenmistry Feb 12 '20 at 12:25
  • for the web. I am not able to set the color just for the web. Why isn't that possible ? – Dimitri Kopriwa Feb 12 '20 at 18:52
  • react-native libraries are best suited for mobile applications only, and they are not meant to compile to html and css. you should be using reactjs for web based matters. – kenmistry Feb 13 '20 at 01:55
  • @kenmistry it looks like you have never used react-native before. FYI, react-native has a replacement for web-based application called react-native-web, making all react-native library can work on the web except if there is native code specific. You can also use `require('react-native').PLATFORM` to detect your OS and execute platform-specific code or name your files with `.web.js`, `.native.js`, `.android.js`, `.ios.js` to import the appropriate source. `react-native-paper` render on the web without pain. It is wrong to say that we MUST use `.css` to style a reactjs components either. – Dimitri Kopriwa Feb 13 '20 at 06:31
  • Also, I am 100% sure that I can style the css by injecting the css in the page myself without using the `PaperProvider`, because this is how HTML works. But that was not what I was asking for. – Dimitri Kopriwa Feb 13 '20 at 06:35
  • i am not entirely sure how you arrive at the conjecture. but if that is the case, can you list a couple of browser websites that have been built using `react-native`, as i am really curious to find out how well it performs and happy to learn more from there. – kenmistry Feb 13 '20 at 06:47
  • 1
    There are plenty, join the discussion and I'll give you mine – Dimitri Kopriwa Feb 13 '20 at 07:10
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/207734/discussion-between-dimitri-kopriwa-and-kenmistry). – Dimitri Kopriwa Feb 13 '20 at 07:10

0 Answers0