question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ThumbColor of Switch not working when switch is true when running app on Web.

See original GitHub issue

Description

The provided thumbColor of the Switch component is not visible when the switch is true on the web. It does work properly on Android and IOS

<Switch thumbColor={"blue"} value={isEnabled} onValueChange={setEnabled}/>

Switch value is true:

image

Switch value is false:

image

React Native version:

System: OS: Windows 10 10.0.18363 CPU: (8) x64 Intel® Core™ i5-8300H CPU @ 2.30GHz Memory: 1.14 GB / 7.74 GB Binaries: Node: 12.18.3 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Not Found Visual Studio: 16.7.30523.141 (Visual Studio Community 2019) Languages: Java: Not Found Python: 3.8.5 npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz => 0.63.2 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps To Reproduce

  1. Create a Switch component from react-native and provide it a thumbColor
  2. Run the app on the web and see that the color is not visible when the value of the switch is true.

Expected Results

The provided thumbColor should be visible when the switch is enabled. Not only when it is disabled.

Snack, code example, screenshot, or link to a repository:

https://snack.expo.io/BY!WFj97J

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

9reactions
rickyplouiscommented, Dec 30, 2020

I ran into the same issue and found out that on react-native-web the Switch component has an activeThumbColor prop that is not in react native. Defer to the react native web docs below for implementation.

http://necolas.github.io/react-native-web/docs/?path=/docs/components-switch--active-thumb-color

6reactions
fuelkoycommented, May 19, 2022

This problem can be fixed with activeThumbColor prop which @rickyplouis pointed out. Set inactive thumbColor in thumbColor prop and active thumbColor in activeThumbColor prop.

Code: thumbColor={ !active ? 'yellow' : undefined} //@ts-expect-error type activeThumbColor={'red'}

@ts-expect-error is there for activeThumbColor because prop is not recognized even it works.

Here are pictures of given props in action inactive: Sieppaa active: Sieppaa2

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change the colour of the Switch thumb in React Native
It turns out the Switch component when used via React Native Web has different props that aren't defined in the types. To fix...
Read more >
Switch - React Native
Switch. Renders a boolean input. This is a controlled component that requires an onValueChange callback that updates the value prop in order ...
Read more >
Cupertino Switch in Flutter - FlutterDevs
}, thumbColor: CupertinoColors.destructiveRed, activeColor: CupertinoColors.activeBlue, ),. When we run the application, we ought to get the screen's ...
Read more >
Error Code 2-ARVHA-0000 (YouTube) - Nintendo Support
Delete the application from the Nintendo Switch and re-download it from the Nintendo eShop. Situation not resolved. Please contact YouTube directly to provide ......
Read more >
Managing Common Toggle Switch State When Changing ...
Using react-native switch works as expected when we use it inside a ... one common switch toggle then it becomes a problem to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found