Button Component

A versatile and customizable button component for React Native applications with multiple variants and styling options.

Features

  • 🎨 Multiple Variants - Primary, Secondary, Outline, and Transparent button styles
  • 🎯 Flexible Styling - Extensive customization options for colors, borders, and dimensions
  • 🔗 Icon Support - Left and right icon placement capabilities
  • Accessibility Ready - Built-in accessibility features
  • 🎨 Theme Integration - Seamlessly integrates with the design system
  • 🎮 Touch Feedback - Configurable opacity and press animations

Installation

💻Bash
npm install rn-base-component
# or
yarn add rn-base-component

Basic Usage

⚛️TSX
import React from 'react'
import { Button } from 'rn-base-component'

export default function App() {
  return 
}

Button Variants

Primary Button

⚛️TSX
import { ButtonPrimary } from 'rn-base-component'
Primary Action

Secondary Button

⚛️TSX
import { ButtonSecondary } from 'rn-base-component'
Secondary Action

Outline Button

⚛️TSX
import { ButtonOutline } from 'rn-base-component'
Outline Button

Transparent Button

⚛️TSX
import { ButtonTransparent } from 'rn-base-component'
Transparent Button

Advanced Usage

With Icons

⚛️TSX
import { Button } from 'rn-base-component'
import { Icon } from 'react-native-vector-icons/MaterialIcons'




Custom Styling

⚛️TSX


const styles = StyleSheet.create({
  customButton: {
    marginVertical: 10,
  },
  customButtonText: {
    fontSize: 18,
    fontWeight: 'bold',
  },
})

Outline Variant

⚛️TSX

Disabled State

⚛️TSX

API Reference

ButtonProps

PropTypeDefaultDescription
textColorstringtheme.textColorColor of the button text
backgroundColorstringtheme.backgroundColorBackground color of the button
disabledbooleanfalseDisable interactions for the component
disabledColorstringtheme.disabledColorBackground color when disabled
outlinebooleanfalseEnable outline style
outlineColorstringtheme.primaryBorderColor of the outline border
outlineWidthnumber1Width of the outline border
borderRadiusnumbertheme.borderRadiusCustom border radius
textSizenumbertheme.fontSizeSize of the button text
leftIconReactNodeundefinedIcon to display on the left side
rightIconReactNodeundefinedIcon to display on the right side
textPropsTextPropsundefinedAdditional props for the text component
textStyleStyleProp<TextStyle>undefinedCustom style for the text
styleStyleProp<ViewStyle>undefinedCustom style for the container

Inherited Props

The Button component also accepts all props from React Native's TouchableOpacityProps.

Common Use Cases

Form Actions

⚛️TSX

  Submit
  Cancel


const styles = StyleSheet.create({
  buttonContainer: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    gap: 12,
  },
})
⚛️TSX

Loading States

⚛️TSX

Best Practices

  1. Consistent Sizing - Use theme values for consistent button heights
  2. Clear Labels - Use descriptive text that clearly indicates the action
  3. Icon Placement - Place icons logically (e.g., arrow-right for "Next")
  4. Loading States - Provide visual feedback during async operations
  5. Accessibility - Ensure sufficient color contrast and touch targets
  6. Disabled States - Clearly indicate when buttons are not interactive

Performance Note

Avoid complex operations in the onPress handler. Use loading states for async operations.