Skip to content

Instantly share code, notes, and snippets.

@LeslieOA
Forked from piaskowyk/OutlineButton.tsx
Created January 22, 2025 07:57
Show Gist options
  • Save LeslieOA/cf1291b157bd6b6f37569687fe552b65 to your computer and use it in GitHub Desktop.
Save LeslieOA/cf1291b157bd6b6f37569687fe552b65 to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import { Pressable, Text } from 'react-native';
import Animated, { css } from 'react-native-reanimated';
export default function OutlineButton() {
const [pressed, setPressed] = useState(false);
const animation1 = {
animationName: css.keyframes({
'0%': {
transform: [{ translateY: -71 }, { scale: 1 }],
opacity: 1,
},
'100%': {
transform: [{ translateY: -71 }, { scale: 1.5 }],
opacity: 0,
},
}),
};
const animation2 = {
animationDelay: 100,
animationName: css.keyframes({
'0%': {
transform: [{ translateY: -71*2 }, { scale: 1 }],
opacity: 1,
},
'100%': {
transform: [{ translateY: -71*2 }, { scale: 1.5 }],
opacity: 0,
},
}),
};
return (
<Pressable onPress={() => setPressed(!pressed)}>
<Animated.View style={styles.button}>
<Text style={styles.text}>CSS Button</Text>
</Animated.View>
<Animated.View style={[styles.buttonBackground, animation1]}/>
<Animated.View style={[styles.buttonBackground, animation2]}/>
</Pressable>
);
}
const styles = css.create({
button: {
backgroundColor: 'rgb(15, 157, 140)',
padding: 20,
borderRadius: 50,
},
buttonBackground: {
borderRadius: 50,
width: 220,
height: 70,
zIndex: -1,
animationTimingFunction: 'easeInOut',
animationFillMode: 'both',
animationDuration: 300,
borderWidth: 5,
borderColor: 'rgb(15, 157, 140)',
opacity: 0,
},
text: {
color: 'white',
fontSize: 30,
textAlign: 'center',
fontWeight: 'bold',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment