Skip to content

Commit 938aa53

Browse files
committed
Add README
1 parent d0377fb commit 938aa53

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# React Native Easing Gradient
2+
3+
Create smooth gradients in React Native
4+
5+
![](demo.png)
6+
7+
## The problem
8+
9+
From https://larsenwork.com/easing-gradients/
10+
11+
> Linear gradients often have hard edges where they start and/or end. We can avoid those by controlling the color mix with easing functions.
12+
13+
## Usage
14+
15+
```js
16+
import { LinearGradient } from 'expo-linear-gradient'
17+
import easeGradient from 'react-native-easing-gradient'
18+
19+
const { colors, locations } = easeGradient({
20+
colorStops: {
21+
0: {
22+
color: 'transparent',
23+
},
24+
1: {
25+
color: '#18181B',
26+
},
27+
},
28+
})
29+
30+
function App() {
31+
return (
32+
<View style={styles.container}>
33+
<LinearGradient
34+
colors={colors}
35+
locations={locations}
36+
style={styles.overlay}
37+
/>
38+
</View>
39+
)
40+
}
41+
```
42+
43+
You can also change the [easing functions](https://reactnative.dev/docs/easing) between the color stops
44+
45+
```js
46+
const { colors, locations } = easeGradient({
47+
colorStops: {
48+
0: {
49+
color: 'transparent',
50+
// This color stop will now use `Easing.linear` instead of `Easing.ease`
51+
easing: Easing.linear,
52+
},
53+
1: {
54+
color: '#18181B',
55+
},
56+
},
57+
// The easing function used on all color stops, defaults to `ease-in-out` (Easing.bezier(0.42, 0, 0.58, 1))
58+
easing: Easing.ease,
59+
})
60+
```
61+
62+
## Credits
63+
64+
- [Easing Linear Gradients](https://css-tricks.com/easing-linear-gradients/)
65+
- [figma-easing-gradient](https://github.com/matchai/figma-easing-gradient)
66+
67+
## Example
68+
69+
To run the example project, follow these steps:
70+
71+
- Clone the repo
72+
- Run these commands
73+
74+
```sh
75+
yarn
76+
cd example
77+
yarn && yarn start
78+
```

demo.png

19.8 KB
Loading

0 commit comments

Comments
 (0)