Fluid Tab Interaction
Monday, January 27, 2025
demos
fluid-tab-interaction
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A customizable segmented control component for React Native featuring smooth animations and blur effects.
Inspiration: Fluid Tab Interaction
Previously, I created a YouTube tutorial demonstrating how to build a similar component (without the animated blur effect).
If you're interested, you can watch the tutorial here: Custom Segmented Control in React Native (Reanimated)
Usage
import { SegmentedControl } from './components/segmented-control';
// Define your data structure
const data = [
{ name: 'Accounts', icon: 'wallet-outline' },
{ name: 'Deposits', icon: 'bank' },
{ name: 'Funds', icon: 'chart-bar' },
];
// Use the component
const MyComponent = () => {
const [selected, setSelected] = useState(data[0]);
const { width } = useWindowDimensions();
return (
<SegmentedControl
data={data}
onPress={setSelected}
selected={selected}
width={width - 40}
height={50}
/>
);
};
Props
The SegmentedControl component accepts the following props:
type SegmentedControlProps<T extends { name: string; icon: string }> = {
data: readonly T[]; // Array of items to display in the control
onPress: (item: T) => void; // Callback function when an item is selected
selected: T; // Currently selected item
width: number; // Width of the control
height: number; // Height of the control
};
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Fluid Tab Interaction
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback