$ git show fab-menu
Speed dial FAB
The plus button turns into an X while action buttons fan out above it, one after another.
+
// Reanimated 4: CSS transitions on the open state, with a per-item delay
import Animated, { cubicBezier } from 'react-native-reanimated';
const [open, setOpen] = useState(false);
const actions = ['camera', 'image', 'file'];
<View style={styles.fabArea}>
{actions.map((icon, i) => (
<Animated.View
key={icon}
pointerEvents={open ? 'auto' : 'none'}
style={[styles.action, {
opacity: open ? 1 : 0,
transform: [{ translateY: open ? -(i + 1) * 60 : 0 }, { scale: open ? 1 : 0.3 }],
transitionProperty: ['transform', 'opacity'],
transitionDuration: '250ms',
transitionTimingFunction: cubicBezier(0.3, 1.4, 0.5, 1), // slight overshoot
transitionDelay: (open ? i : actions.length - 1 - i) * 40 + 'ms', // stagger, reversed on close
}]}>
<ActionButton icon={icon} />
</Animated.View>
))}
<Pressable onPress={() => setOpen(o => !o)}>
<Animated.View style={[styles.fab, {
transform: [{ rotate: open ? '45deg' : '0deg' }],
transitionProperty: 'transform',
transitionDuration: '200ms',
}]}>
<PlusIcon />
</Animated.View>
</Pressable>
</View>