Search code examples
cssreactjsreact-nativeviewdropshadow

Drop shadow for a line in react native


I want to implement a drop shadow for a line something like this:

enter image description here

What I did so far:

<View style=
  {{
    elevation: 5,
    borderBottomWidth: 2,
    bottom: 1,
  }}
>
</View>

Solution

  • import Svg, { LinearGradient, Defs, Stop, Rect } from 'react-native-svg'
    
    <Svg height="100" width="100%" style={{ zIndex: 1, marginTop: -50 }}>
        <Defs>
            <LinearGradient id="grad" x1="0" y1="0" x2="0" y2="1">
                <Stop offset="0" stopColor="#e6e6e6" stopOpacity="1" />
                <Stop offset="1" stopColor="#e6e6e6" stopOpacity="0.01" />
            </LinearGradient>
        </Defs>
        <Rect height="100" width="100%" fill="url(#grad)" />
    </Svg>