I have a linear gradient in css linear-gradient(315.43deg, #706EB6 -6.67%, #A57FCF 106.6%) and i want to use with the component LinearGradient in react native. What are the equivalents of start, end and locations props and How can i pass from linear gradient in css to react native ?
Add a comment
|
1 Answer
In React Native you can use colors property like this
<LinearGradient colors={['transparent', '#000000']}>
</LinearGradient>
In the same way, you can pass the start, end positions
You can see the props of LinearGradient here
declare module 'react-native-linear-gradient' {
import * as React from 'react';
import * as ReactNative from 'react-native';
export interface LinearGradientProps extends ReactNative.ViewProps {
colors: (string | number)[];
start?: { x: number; y: number };
end?: { x: number; y: number };
locations?: number[];
useAngle?: boolean;
angleCenter?: {x: number, y: number};
angle?: number;
}
export class LinearGradient extends React.Component<LinearGradientProps> {}
export default LinearGradient;
}
2 Comments
Abdo Rabah
Thanks for the explanation. But how can i pass from linear gradient in css to react native ?
Rahul Khurana
@AbdoRabah We can't do this in React-native. CSS is used on the web. In the mobile apps, you have to use the alternate methods provided