fix: Force PrimaryButton text color in all states #2364
Merged
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.
Summary
The
PrimaryButton
styling works great when there are no conflicting styles. However, the state pseudo selectors take an unopinionated approach on the text color of the button, which makes it easily overridden by globally scoped css (particularly when usingas="a"
).In platforms like Docusaurus, it's common to have styling for
a:hover
. SincePrimaryButton
does not have anycolor
set for:hover
(or other states), this gets overridden by a simple global specifier, resulting in something that looks like this:While I could add another style for
a[type="button"]:hover { color: #fff }
, this would cause other problems because we have no way of determining via DOM aPrimaryButton
from aSecondaryButton
. If this rule were applied to a SecondaryButton, the text would be invisible on a white background.The simplest approach here IMO was to take a slightly more assertive approach in specifying the color for all states. I don't believe this should have any negative effects, and I don't think it should be a breaking change.
I believe buttons have been largely re-written in v10 👑 , so this may need to be ported to the prerelease branch as well.
Thanks for the consideration!
Release Category
Components
Checklist
ready for review
has been added to PRFor the Reviewer