The recommended way to use the component is by defining a PresetConfig object. This object allows you to define a metadata block and a states array. Each state (like default, hover, or press) contains its own preset configuration, including glowLayers, cornerRadius, outlineWidth, and borderColor. The library will automatically interpolate between these states using Reanimated.
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import AnimatedGlow, { type PresetConfig } from 'react-native-animated-glow';
// 1. Define your preset
const myCoolPreset: PresetConfig = {
metadata: {
name: 'My Cool Preset',
textColor: '#FFFFFF',
category: 'Custom',
tags: ['interactive']
},
states: [
{
name: 'default', // The base style for the component
preset: {
cornerRadius: 50,
outlineWidth: 2,
borderColor: '#E0FFFF',
glowLayers: [
{ colors: ['#00BFFF', '#87CEEB'], opacity: 0.5, glowSize: 30 },
]
}
},
// 2. Define interactive states
{
name: 'hover',
transition: 300, // 300ms transition into this state
preset: {
glowLayers: [{ glowSize: 40 }] // On hover, make the glow bigger
}
},
{
name: 'press',
transition: 100, // A faster transition for press
preset: {
glowLayers: [{ glowSize: 45, opacity: 0.6 }]
}
}
]
};
// 3. Use it in your component
export default function MyGlowingComponent() {
return (
<AnimatedGlow preset={myCoolPreset}>
<View style={styles.box}>
<Text style={styles.text}>I'm Interactive!</Text>
</View>
</AnimatedGlow>
);
}
const styles = StyleSheet.create({
box: { paddingVertical: 20, paddingHorizontal: 40, backgroundColor: '#222' },
text: { color: 'white', fontWeight: 'bold' }
});