@masumdev/rn-fab
A highly customizable Floating Action Button (FAB) component for React Native. Supports multiple variants including single, extended, stacked, clustered, and doted layouts. Built with smooth animations and optimized for both iOS and Android platforms.

Demo
Youtube Tutorial
Features
- 🚀 Multiple FAB variants (Single, Extended, Stacked, Clustered, Doted)
- 🎨 Customizable themes (Light/Dark)
- 🔄 Smooth animations and transitions
- 📱 Works on iOS and Android
- 📚 TypeScript support
- 🎯 Support for custom icons and components
- 🔍 Flexible positioning and styling
Installation
Prerequisites
-
Make sure you have React Native project set up with the following peer dependencies:
{
"react": "^18.2.0",
"react-native": "^0.76.9",
"react-native-reanimated": "^3.16.7",
}
npm install react-native-reanimated
yarn add react-native-reanimated
pnpm add react-native-reanimated
bun add react-native-reanimated
-
Reanimated plugin setup:
If you are using Expo, you need to configure the Reanimated plugin in your babel.config.js
file. Add the following configuration:
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
};
};
-
Install the library:
npm install @masumdev/rn-fab
yarn add @masumdev/rn-fab
pnpm install @masumdev/rn-fab
bun add @masumdev/rn-fab
Usage
Basic Setup
import { Fab } from '@masumdev/rn-fab';
import { View } from 'react-native';
import { PlusIcon, EditIcon, TrashIcon } from 'lucide-react-native';
export const SingleFAB = () => (
<Fab
variant="single"
icon={<PlusIcon color="white" />}
onPress={() => console.log('FAB pressed')}
theme="light"
style={{ backgroundColor: '#007AFF' }}
/>
);
export const ExtendedFAB = () => (
<Fab
variant="extended"
items={[
{
icon: <EditIcon color="white" />,
label: "Edit",
onPress: () => console.log('Edit pressed')
}
]}
theme="light"
/>
);
export const StackedFAB = () => (
<Fab
variant="stacked"
items={[
{
icon: <EditIcon color="white" />,
onPress: () => console.log('Edit')
},
{
icon: <TrashIcon color="white" />,
onPress: () => console.log('Delete')
}
]}
theme="light"
/>
);
Configuration Options
Each FAB variant supports these common props:
type CommonProps = {
theme?: 'light' | 'dark';
style?: ViewStyle;
containerStyle?: ViewStyle;
plusIcon?: React.ReactNode;
isOpen?: (prev: boolean) => void;
};
type FabItem = {
icon: React.ReactNode;
onPress: () => void;
label?: string;
};
Advanced Usage
const ClusteredFAB = () => (
<Fab
variant="clustered"
items={[
{
icon: <CameraIcon color="white" />,
label: "Camera",
onPress: () => console.log('Camera')
},
{
icon: <GalleryIcon color="white" />,
label: "Gallery",
onPress: () => console.log('Gallery')
}
]}
theme="light"
isOpen={(open) => console.log('FAB is open:', open)}
/>
);
const DotedFAB = () => (
<Fab
variant="doted"
items={[
{
icon: <HomeIcon color="white" />,
onPress: () => console.log('Home')
},
{
icon: <SettingsIcon color="white" />,
onPress: () => console.log('Settings')
}
]}
theme="light"
plusIcon={<CustomPlusIcon />}
/>
);
API Reference
Common Props
Props available for all FAB variants:
theme | 'light' | 'dark' | 'light' | FAB display theme |
style | ViewStyle | - | Custom styles for FAB |
containerStyle | ViewStyle | - | Custom styles for FAB container |
plusIcon | ReactNode | - | Custom icon for plus button |
isOpen | (prev: boolean) => void | - | Callback when FAB is opened/closed |
FAB Variants
Single FAB
Basic FAB with a single action.
variant | 'single' | Yes | FAB variant type |
icon | ReactNode | No | Icon component |
onPress | () => void | No | Callback when FAB is pressed |
Extended FAB
FAB with text label next to the icon.
variant | 'extended' | Yes | FAB variant type |
items | Array | Yes | Array of 1-3 FAB items |
Tipe ExtendedItem
:
{
icon: ReactNode;
onPress: () => void;
label: string;
}
Stacked FAB
Vertically stacked FAB.
variant | 'stacked' | Yes | FAB variant type |
items | Array | Yes | Array of 1-3 FAB items |
Tipe StackedItem
:
{
icon: ReactNode;
onPress: () => void;
}
Clustered FAB
FAB with labels arranged in an arc.
variant | 'clustered' | Yes | FAB variant type |
items | Array | Yes | Array of 1-3 FAB items |
Tipe ClusteredItem
:
{
icon: ReactNode;
onPress: () => void;
label: string;
}
Doted FAB
FAB with dot indicators.
variant | 'doted' | Yes | FAB variant type |
items | Array | Yes | Array of 1-3 FAB items |
Tipe DotedItem
:
{
icon: ReactNode;
onPress: () => void;
}
Theme Options
light | Light background with dark icons |
dark | Dark background with light icons |
License
MIT