YPE-1320: scope Tailwind preflight CSS to SDK components only#146
YPE-1320: scope Tailwind preflight CSS to SDK components only#146cameronapak merged 7 commits intomainfrom
Conversation
Move Tailwind preflight resets to be scoped within the `[data-yv-sdk]` attribute. This prevents them from affecting consumer application styles while still applying necessary resets to SDK components.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
🦋 Changeset detectedLatest commit: 32dba19 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Greptile OverviewGreptile SummaryReplaced the global Key changes:
Analysis: Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 7e248f6 |
Use `:where()` to reduce specificity of Tailwind's reset CSS within `[data-yv-sdk]`. This ensures that user-provided styles will correctly override the reset.
8c8f3d8 to
7e248f6
Compare
|
@greptileai, update the description of this PR and then re-review |
bmanquen
left a comment
There was a problem hiding this comment.
I built it and checked the dist file but don't know how else I can verify this is working. I do find one * global selector in the distributed css file. This is also the case on main tho so not sure if I see a difference.
I might be missing something though.
|
This has been addressed and fixed @bmanquen !
|



https://lifechurch.atlassian.net/browse/YPE-1320
Problem
When consumers import our SDK (
@youversion/platform-react-ui), Tailwind's preflight CSS resets are applied globally to the entire page. This causes the consumer app's styles to be overridden — for example:h1–h6headings lose their font size and weight (font-size: inherit; font-weight: inherit)margin: 0; padding: 0; box-sizing: border-boxforced on themThis happens because
@import 'tailwindcss/preflight.css'inglobal.cssemits unscoped selectors like*,h1, h2, h3..., etc. that affect the entire DOM — not just our SDK components.Solution
Replaced the global
@import 'tailwindcss/preflight.css'with a scoped preflight that nests all reset rules under[data-yv-sdk]. Since all our SDK components already render a root element withdata-yv-sdk, the preflight resets now only apply inside our components.This means:
h1sizes, margins, list bullets, etc.) are no longer clobberedVerification
build:csscompiles successfully*selectors — all preflight is scoped to[data-yv-sdk]