Skip to content

SVG descendant styles not being applied in dark mode #2177

Open
@jordmccord

Description

@jordmccord

Description

When applying descendant styles to an SVG color prop they change in dark mode.

CodeSandbox/Snack link

/

Steps to reproduce

  1. Create styled component using Svg from react-native-svg e.g:
import { styled } from '@gluestack-style/react';

import { Svg } from 'react-native-svg';

const SpinnerSVG = styled(
  Svg,
  {
    color: '$purple800',
    _dark: {
      color: '$darkPurple800',
    },
  },
  {
    componentName: 'SpinnerSvg',
    ancestorStyle: ['_svg'],
    descendantStyle: ['_circle'],
  }
);

export default SpinnerSVG;
  1. Use that component in a parent component like Button
  2. Style the child component e.g Button.ts blue variant:
...
blue: {
  _spinner: {
    _svg: {
      color: '$blue400',
    },
  },
  _dark: {
    _spinner: {
      _svg: {
        color: '$darkBlue400',
      },
    }
  }
}
...
  1. See the SVG color only change in light mode

Screenshot 2024-05-22 at 10 58 34
Light mode changes color

Screenshot 2024-05-22 at 10 58 43
Dark mode reverts to default colour

gluestack-ui Version

@gluestack-style/react@1.0.56, @gluestack-ui/themed@1.1.26

Platform

  • Expo
  • React Native CLI
  • Next
  • Web
  • Android
  • iOS

Other Platform

No response

Additional Information

There is also a TS error saying color prop doesn't exist in dark mode see:
Screenshot 2024-05-22 at 10 59 05

Works fine on web but not on Android or iOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggluestack-styleIssue related to gluestack-stylev1gluestack-ui v1

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions