feat: add cursor CSS property support#346
Open
adrianorocha-dev wants to merge 1 commit into
Open
Conversation
Register a parser for the CSS `cursor` property so that Tailwind classes like `cursor-pointer` compile to the native `cursor` style prop on react-native-macos and react-native-windows. Only the keyword value is extracted (e.g. pointer, auto, default). Cursor images (`cursor: url(...), pointer`) are not handled since React Native does not support custom cursor images. iOS and Android silently ignore the cursor style prop, so this is safe cross-platform.
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.
Summary
Add compiler support for the CSS
cursorproperty, enabling Tailwind classes likecursor-pointer,cursor-auto, andcursor-defaultto compile to the nativecursorstyle prop.This is targeted at react-native-macos and react-native-windows, which both support
cursoras a native style property (viaStyleSheet.createor inline styles). iOS and Android silently ignore the prop, so this change is safe cross-platform.Currently, lightningcss parses
cursordeclarations correctly, but the compiler has no parser registered for it — the property is silently dropped with a warning. This PR fixes that.Also fixes a duplicate
cursor-defaulttest in the Tailwind interactivity tests (replaced the second one withcursor-pointer).Implementation
The parser extracts
value.keywordfrom the lightningcssCursorAST ({ images: CursorImage[], keyword: CursorKeyword }). Only the keyword is used — cursor images (e.g.cursor: url(...), pointer) are not handled since React Native does not support custom cursor images.Similar to
parseUserSelectandparsePointerEvents.Test plan
cursor: pointer;andcursor: auto;cursor-defaulttest →cursor-pointeryarn test)