0

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 ?

1 Answer 1

1

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;
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the explanation. But how can i pass from linear gradient in css to react native ?
@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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.