@grishjoshi/react-native-custom-button
v0.1.0
Published
A highly customizable button component for React Native
Maintainers
Readme
react-native-custom-button
A highly customizable, production-ready button component for React Native, supporting iOS, Android, and Expo. Built with TypeScript, Reanimated, and LinearGradient.
Features
- 🎨 6 Button Variants: Primary, Secondary, Tertiary, Elevated, Outlined, Text.
- 🌈 Gradient Support: Linear gradients with angle control.
- ✨ Rich Animations: Scale interactions, customizable ripples, and loading states.
- 🔧 Highly Customizable: extensive styling props and theme support.
- ♿ Accessible: WCAG compliant touch targets and accessibility props.
- 📱 Cross-Platform: Works on iOS, Android, and Web (with caveats).
Installation
npm install react-native-custom-button
# or
yarn add react-native-custom-buttonPeer Dependencies
You need to install these packages if you haven't already:
npm install react-native-reanimated react-native-linear-gradient
# or
yarn add react-native-reanimated react-native-linear-gradientDon't forget to configure react-native-reanimated in your babel.config.js.
Usage
import React from 'react';
import { View } from 'react-native';
import { CustomButton } from 'react-native-custom-button';
const App = () => {
return (
<View style={{ padding: 20, gap: 10 }}>
{/* Primary Button */}
<CustomButton
title="Primary Action"
onPress={() => console.log('Pressed')}
/>
{/* Gradient Button */}
<CustomButton
title="Gradient Button"
gradientColors={['#4c669f', '#3b5998', '#192f6a']}
onPress={() => {}}
/>
{/* Loading State */}
<CustomButton
title="Loading..."
loading
variant="secondary"
/>
{/* Icon Button */}
<CustomButton
title="Settings"
variant="outlined"
leftIcon={<SomeIconComponent />}
/>
</View>
);
};Feature Showcase
Glowing Button
A continuous rotating glow effect, perfect for AI modes or highlighting special actions.
<CustomButton
title="Dive deeper in AI Mode"
onPress={() => Alert.alert('Glowing Button!')}
glow
glowColors={['#4285F4', '#46a05bff', '#FFD700']}
glowDuration={5000}
backgroundColor="#4968c6ff"
style={{ width: 300, height: 60, borderRadius: 30 }}
/>Advanced Gradients
Full control over gradient colors and direction.
<CustomButton
title="Ocean Gradient"
gradientColors={['#2193b0', '#6dd5ed']}
gradientStart="top-left"
gradientEnd="bottom-right"
onPress={() => {}}
style={{ marginTop: 10 }}
/>States (Loading & Disabled)
<CustomButton title="Loading" loading variant="secondary" onPress={() => {}} />
<CustomButton title="Disabled" disabled onPress={() => {}} style={{ marginTop: 10 }} />Custom Theming with Icons
Deeply customize appearance and layout.
<CustomButton
title="Custom Themed"
backgroundColor="#40cc7dff"
variant="primary"
textStyle={{ fontSize: 24 }}
style={{ width: "100%", height: 50, borderRadius: 20 }}
leftIcon={<MaterialIcons name="add" size={24} color="white" />}
rightIcon={<MaterialIcons name="send" size={24} color="black" />}
spacing={20}
onPress={() => {}}
/>Floating Action Button (FAB)
A dedicated compound component for FABs.
<CustomButton.Floating
// Core styling
style={{ width: 64, height: 64, borderRadius: 32 }}
backgroundColor="#4966bfff"
// Positioning
floatingPosition="bottom-right"
offset={{ x: 20, y: 10 }}
// Interact
onPress={() => Alert.alert('Super FAB Pressed')}
>
<MaterialIcons name="add" size={30} color="white" /> //inside floating button
</CustomButton.Floating>FAB Customization
The CustomButton.Floating component is designed to hover above your content. To ensure it stays fixed while scrolling, place it outside your ScrollView or FlatList.
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| floatingPosition | 'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' | 'bottom-right' | Corner to anchor the button. |
| offset | { x: number, y: number } | { x: 20, y: 20 } | Distance from the edge. |
| label | string | - | If provided, creates an "Extended FAB" with text. |
| style | ViewStyle | - | Override dimensions, colors, or shadows. |
Note: For the FAB to float correctly over scrollable content, ensure its parent container has
flex: 1relative to the screen, and the FAB is a sibling to the ScrollView, not a child.
Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| title | string | - | The text to display. |
| variant | 'primary' \| 'secondary' \| 'tertiary' \| 'elevated' \| 'outlined' \| 'text' | 'primary' | The visual style variants. |
| size | 'small' \| 'medium' \| 'large' | 'medium' | Predefined sizes. |
| loading | boolean | false | Shows a loading spinner. |
| disabled | boolean | false | Disables interaction and modifies styles. |
| gradientColors | string[] | - | Array of colors for background gradient. |
| leftIcon | ReactNode | - | Element to render on the left. |
| rightIcon | ReactNode | - | Element to render on the right. |
| theme | ButtonTheme | - | Override default theme tokens. |
| ...and standard Pressable props. |
License
MIT License
Copyright (c) 2025
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
