Skip to main content

AnimatedFAB

An animated, extending horizontally floating action button represents the primary action in an application.

How to use

import React from 'react';
import {AnimatedFAB, SafeAreaView, ScrollView} from '@gyri/native-ui-components';

const MyComponent = ({style, className}) => {
const [isExtended, setIsExtended] = React.useState(true);

const onScroll = ({ nativeEvent }) => {
const currentScrollPosition =
Math.floor(nativeEvent?.contentOffset?.y) ?? 0;

setIsExtended(currentScrollPosition <= 0);
};

return (
<SafeAreaView>
<ScrollView onScroll={onScroll}>
{[...new Array(100).keys()].map((_, i) => (
<Text>{i}</Text>
))}
</ScrollView>
<AnimatedFAB
style={style}
className={className}
icon={'plus'}
label={'Label'}
extended={isExtended}
onPress={() => console.log('Pressed')}
visible={visible}
animateFrom={'right'}
iconMode={'static'}
/>
</SafeAreaView>
)
};

export default MyComponent;

Props

#NameData typeDefault valueValuesDescription
1styleobjectCustom style object
2classNamestring''It defined nativewind style classes.
3colorstringCustom color for the icon and label of the FAB
4iconIcon to display for the FAB.
5rippleColorColor of the ripple effect.
6visiblebooleantrueWhether FAB is currently visible.
7iconModedynamic'static' , 'dynamic'Whether icon should be translated to the end of extended FAB or be static and stay in the same place.
8animateFromright'left', 'right'Indicates from which direction animation should be performed.
9extendedbooleanfalseWhether FAB should start animation to extend.

For more details https://callstack.github.io/react-native-paper/docs/components/FAB/AnimatedFAB