- Primary Variant
- Secondary Variant
- Disabled State
Button Component
TheButton component is an animated, theme-aware button with spring-based press animations. It supports primary and secondary variants with automatic text color handling.
Import
Basic Usage
Props
Callback function invoked when the button is pressed
The content to display inside the button (typically text)
Additional styles to apply to the button container
Whether the button is disabled. Disabled buttons have reduced opacity and don’t respond to press events
Visual variant of the button:
primary: Usestheme.linkbackground withtheme.buttonTexttext colorsecondary: Usestheme.backgroundSecondarybackground withtheme.texttext color
Real-World Examples
Workout Completion
FromWorkoutScreen.tsx:486-488:
Modal Actions
FromWorkoutScreen.tsx:569-581:
Animation Behavior
The Button component usesreact-native-reanimated for smooth press animations:
Press Animation
- Press In: Scales down to 0.98 with spring physics
- Press Out: Springs back to 1.0 scale
- Disabled State: No animation occurs
Spring Configuration
Styling
Default Styles
Custom Styling
Theme Integration
The Button automatically adapts to the current theme:Accessibility
Touch Target
The button has a minimum height ofSpacing.buttonHeight to ensure an accessible touch target size.
Visual Feedback
- Animated scale provides clear visual feedback
- Disabled state is visually distinct with reduced opacity
- High contrast between background and text colors
TypeScript Interface
Best Practices
Use descriptive button text
Use descriptive button text
Choose the right variant
Choose the right variant
Use
primary for the main action and secondary for alternative or cancel actions:Provide loading states
Provide loading states
Use the
disabled prop during async operations:Source Code
Location:client/components/Button.tsx
The Button component is built using:
react-native-reanimatedfor animationsThemedTextfor consistent typographyuseThemehook for theme integration