$ git show chip-select
Filter chips
Tapping a chip fills it and grows a check mark, and the chips around it slide over to make room.
✓ VeganQuickSpicy
// Reanimated 4: layout animations still reflow the row; the chip colors use a CSS transition
import Animated, { LinearTransition, ZoomIn, ZoomOut } from 'react-native-reanimated';
const [selected, setSelected] = useState(new Set(['Vegan']));
const toggle = (tag) => setSelected((s) => {
const next = new Set(s);
next.has(tag) ? next.delete(tag) : next.add(tag);
return next;
});
<View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
{TAGS.map((tag) => {
const on = selected.has(tag);
return (
<Animated.View key={tag} layout={LinearTransition.springify().damping(18)}>
<Pressable onPress={() => toggle(tag)}>
<Animated.View style={[styles.chip, {
backgroundColor: on ? '#2F54EB' : 'white',
borderColor: on ? '#2F54EB' : '#DADFE6',
transitionProperty: ['backgroundColor', 'borderColor'],
transitionDuration: '180ms',
}]}>
{on && (
<Animated.View entering={ZoomIn.springify()} exiting={ZoomOut.duration(120)}>
<CheckIcon size={14} color="white" />
</Animated.View>
)}
<Text style={[styles.chipText, on && { color: 'white' }]}>{tag}</Text>
</Animated.View>
</Pressable>
</Animated.View>
);
})}
</View>