fix(theme): allow for simplified input styling #8364
Closed
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.
📝 Description
This change allows users to style
Input
components viaInputGroup
without those styles being overridden by theInput
itself.⛳️ Current behavior (updates)
The
Input
component can be styled by setting some custom CSS variables:These CSS variables are also used by
InputGroup
and theInputLeftAddon/InputRightAddon
andInputLeftElement/InputRightElement
components to allow them to share size information with theInput
to create a seamless end result.Unfortunately, if you want to adjust any of these values in a one-off scenario, you have to apply the new value to the
InputGroup
and to theInput
, because theInput
has its own copy of the CSS variables which take precedence.🚀 New behavior
This PR changes the keys of the CSS variables set on the
Input
itself to this set:It then adjusts the corresponding properties of an
Input
to use the original set with a fallback to the new set:This lets a user set the original variable once on the
InputGroup
and have it inherit throughout the other group components.💣 Is this a breaking change (Yes/No):
No - if a user is already dealing with this issue by setting the original CSS vars in two places, that will continue to work due to the CSS variable fallback arrangement.
📝 Additional Information
It's my understanding that the reason this has to be solved with two CSS variables is because Chakra doesn't allow theme tokens in CSS variable fallback values. Having the fallback be another variable which can be set with a theme token means we can avoid hard-coding any CSS values.