Loading Button
How to use loading states in React Button Pro
Loading Button
Learn how to use loading states to provide feedback during asynchronous operations.
Default Loading
Custom Loading Spinner
Usage
Basic Loading State
With Custom Spinner Color
With Custom Spinner Component
Props
Prop | Type | Default | Description |
---|---|---|---|
isLoading | boolean | false | Whether the button is in a loading state |
spinner | ReactNode | - | Custom spinner component |
spinnerColor | ButtonColor | - | Color of the default spinner |
Best Practices
-
User Feedback:
- Show loading state immediately
- Maintain button width during loading
- Provide clear loading text
- Consider animation duration
-
Accessibility:
- Maintain ARIA attributes
- Keep button disabled during loading
- Provide screen reader feedback
- Consider reduced motion
-
UX Considerations:
- Use appropriate loading duration
- Show progress when possible
- Consider optimistic updates
- Handle errors gracefully
-
Implementation:
- Manage loading state properly
- Handle component unmounting
- Clean up async operations
- Consider loading timeouts
Examples
With Form Submission
With Different Variants
With Custom Loading Text
Last updated on