-
Notifications
You must be signed in to change notification settings - Fork 953
feat(button): add loadingPosition prop for loading icon placement control #5456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v4
Are you sure you want to change the base?
feat(button): add loadingPosition prop for loading icon placement control #5456
Conversation
Add a new `loadingPosition` prop to the Button component that allows developers to control where the loading icon appears when the button is in a loading state. The prop accepts three values: - 'left': displays loading icon on the left (default behavior) - 'center': displays loading icon in the center, hiding the label - 'right': displays loading icon on the right The implementation maintains full backward compatibility. Existing usage with `leading` and `trailing` props for loading buttons continues to work without any changes. When `loadingPosition` is not specified, the component automatically determines the position based on the `trailing` prop, preserving the existing behavior. Adds test cases for all three loadingPosition values to ensure proper rendering and behavior.
Add documentation section for the new `loading-position` prop in the Button component. The section includes: - Description of the three position options (left, center, right) - Code examples for each position option - Backward compatibility note explaining that existing usage with `leading` and `trailing` props continues to work This documentation helps developers understand how to control the loading icon placement when using the Button component in loading state.
commit: |
|
Thank you! :) |
|
First off -- thank you. I have some comments and questions.
|
|
Questions are always welcome!π€
|
|
I just looked at the implementation, and The implemented behaviour (label disappears completely and is replaced by the loading icon, changing the width of the button): Screencast.From.2025-11-15.15-55-30.mp4The behaviour described in the issue (label and other icons receive Screencast.From.2025-11-15.15-57-40.mp4 |
|
@rijenkii 2025-11-15.8.27.12.mov |
When loadingPosition is set to 'center' and a label is provided, the button now maintains the label's width even though the label is hidden. The loading icon is displayed in the center of the button while preserving the original button width. Changes: - Add loadingIcon and loadingLabel slots to button theme - Add animate-spin class to loadingIcon when loading is true - Update Button component to render label with opacity-0 and h-0 when loadingPosition is center - Update test snapshots to reflect the new structure

π Linked issue
#5362
β Type of change
π Description
Adds a new
loadingPositionprop to the Button component that allows developers to control where the loading icon appears when the button is in a loading state.Features:
left,center, andrightleft: displays loading icon on the left (default behavior)center: displays loading icon in the center, hiding the labelright: displays loading icon on the right2025-11-15.10.17.50.mov
Backward Compatibility:
leadingandtrailingprops continues to work without any changesloadingPositionis not specified, the component automatically determines the position based on thetrailingpropImplementation Details:
loadingPositionprop toButtonPropsinterfaceuseComponentIconslogic to handle position-based loading icon placementDocumentation:
π Checklist