feat: add Switch thumb-* and track-* color utilities#1826
Open
patrickwehbe wants to merge 1 commit into
Open
Conversation
Map thumb-* and track-* to the React Native Switch thumbColor and trackColor props via @prop, mirroring the existing tint-* utility. These utilities existed in v4 but were missing in v5. Closes nativewind#1757
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds two custom utilities to
theme.css:thumb-*maps a color to the React Native SwitchthumbColorproptrack-*maps a color to the React Native SwitchtrackColorpropBoth follow the same
@proppattern as the existingtint-*utility, reading the value from--color-*.Why
Fixes #1757. v4 provided
thumb-*utilities and track color values for styling the Switch component, and these were not listed in the migration guide as intentionally removed. This restores that behavior in v5. The mapping approach (color tothumbColor/trackColorvia@prop) matches what was suggested in the issue.Tests
Added
src/__tests__/switch.tsxcoveringthumb-blackandtrack-black, following the existing test conventions. The full suite passes: