$ git show floating-label
Floating label
The placeholder shrinks and floats above the input when it's focused or filled.
Email
// Reanimated 4: a CSS transition follows the focused / filled state
const [focused, setFocused] = useState(false);
const [value, setValue] = useState('');
const up = focused || value.length > 0;
<View style={styles.field}>
{/* styles.label: position 'absolute', left 12, top 14, transformOrigin 'left' */}
<Animated.Text
pointerEvents="none"
style={[styles.label, {
transform: [{ translateY: up ? -22 : 0 }, { scale: up ? 0.8 : 1 }],
color: up ? '#2F5BFF' : '#888888',
transitionProperty: ['transform', 'color'],
transitionDuration: '180ms',
transitionTimingFunction: 'ease-out',
}]}>
Email
</Animated.Text>
<TextInput
value={value}
onChangeText={setValue}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
style={styles.input}
/>
</View>