Skip to content

border-color opacity level is not visible when a background-color without opacity is set on the same view (iOS)Β #39286

@flo-sch

Description

@flo-sch

Description

On a given <View />, when applying a background color without opacity, together with a border-color having an opacity level, the border-color appears opaque on iOS, while it appears as expected on Android.

<View
  style={{
    width: 20,
    height: 20,
    borderRadius: 10,
    backgroundColor: 'rgb(208, 12, 123)',
    borderStyle: 'solid',
    borderWidth: 2,
    borderColor: 'rgba(208, 12, 123, 0.2)',
  }}
/>

As shown on the screenshots below, the border-color has a visual opacity value on Android, but is rendered "opaque" on iOS, as if the opacity of the background-color takes over the opacity of the border-color.

react-native-border-color-opacity-android react-native-border-color-opacity-ios

It is possible to workaround that for my case by adding the opaque background on a child View, but I am interested to know whether this is intentional behaviour or not.

React Native Version

0.71.11

Output of npx react-native info

info Fetching system and libraries information...
System:
    OS: macOS 13.5.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 22.72 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.12.0 - /[...]/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.3 AI-223.8836.35.2231.10671973
    Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild
  Languages:
    Java: 20.0.1 - /usr/local/opt/openjdk/bin/javac
  npmPackages:
    @react-native-community/cli: 10.1.3 => 10.1.3 
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.11 => 0.71.11 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  • Implement a View of any dimension
  • Give it an opaque background-color (ex rgb(255, 0, 0))
  • Give it a border of style solid, a width, and an non-opaque background-color (ex: rgba(255, 0, 0, 0.2))
  • Compare how it visually differs between Android and iOS

Snack, screenshot, or link to a repository

https://snack.expo.dev/@flo-sch/react-native-background-vs-border-color-opacity

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions