Installation
The Button component requires the following dependencies:- This is already installed in the project.
How to Import?
Features
- Haptic feedback support (on native platforms)
- Loading state with ActivityIndicator
- Icon support (left or right positioned)
- Customizable styling
- Theme integration
- Disabled state
- Pressed state animation
- TypeScript support
Props
Usage
Basic Usage
With Loading State
With Icon
Custom Styling
Don’t forget to use
constants/appConstants.ts to defining your theme.Styling
The button comes with default styles that can be customized:- Default border radius from
BORDER_RADIUS.sm - Flexible height (default from
BUTTON_HEIGHT.md) - Pressed state reduces opacity to 0.8 and scales to 0.99
- Disabled state reduces opacity to 0.5
- Icons have horizontal margin from
MARGIN.sm
Theme Integration
The button automatically integrates with your app’s theme system using theuseTheme hook:
Notes
- Haptic feedback is automatically triggered on button press (native platforms only)
- Loading state automatically disables the button
- The button supports both single and array style props for flexible styling
- Icons are wrapped in a View container with horizontal margin
- The component is fully type-safe with TypeScript
Best Practices
- Always provide a meaningful onPress handler
- Use loading state for async operations
- Provide appropriate feedback for disabled states
- Consider using icons to enhance visual communication
- Maintain consistent styling across your application
- Use the theme system for consistent color schemes