fix: #7630: Apply ToggleButton className prop to box element #7631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #7630
This PR updates the
ToggleButton
component to apply theclassName
prop directly to the box element (wrapper) instead of the parent container. This change allows developers to style the component's wrapper element more effectively and dynamically based on itschecked
state or other conditions.Previously, the
className
prop was applied to the parent container that wraps theinput
andbutton
elements, which made it difficult to style the component dynamically. For instance, changing the button's background color or other visual properties based on itschecked
state was unintuitive and required additional workarounds.By applying the
className
to the box element, developers can now easily control the visual appearance of theToggleButton
without modifying the underlying DOM structure.className
application logic in theToggleButton
component to target the box element.checked
andunchecked
) and themes.Example Usage
Here is an example showcasing how this fix enables more intuitive dynamic styling:
Output After the Fix
After this change, the className correctly applies to the box element, enabling dynamic styling. Here is the updated output:
With this fix, the className dynamically applies the appropriate background color based on the checked state of the ToggleButton.
Notes
• Backward Compatibility: This change should not break any existing usage of the ToggleButton component.
• Testing: Verified with various custom className values, states, and themes.
Let me know if additional adjustments are needed!