Skip to content

YPE-1320: scope Tailwind preflight CSS to SDK components only#146

Merged
cameronapak merged 7 commits intomainfrom
cam/css-issues-v3
Feb 16, 2026
Merged

YPE-1320: scope Tailwind preflight CSS to SDK components only#146
cameronapak merged 7 commits intomainfrom
cam/css-issues-v3

Conversation

@cameronapak
Copy link
Collaborator

@cameronapak cameronapak commented Feb 13, 2026

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:

  • h1h6 headings lose their font size and weight (font-size: inherit; font-weight: inherit)
  • All elements get margin: 0; padding: 0; box-sizing: border-box forced on them
  • Lists, images, links, and form elements are reset unexpectedly

This happens because @import 'tailwindcss/preflight.css' in global.css emits 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 with data-yv-sdk, the preflight resets now only apply inside our components.

This means:

  • ✅ SDK components still get the full Tailwind preflight reset they need
  • ✅ Consumer app styles (h1 sizes, margins, list bullets, etc.) are no longer clobbered
  • ✅ No changes needed in consumer apps or in our component code

Verification

  • build:css compiles successfully
  • Built output contains zero global * selectors — all preflight is scoped to [data-yv-sdk]
  • All unit tests pass

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.
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: 32dba19

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-react-ui Patch
@youversion/platform-core Patch
@youversion/platform-react-hooks Patch
nextjs Patch

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-apps
Copy link
Contributor

greptile-apps bot commented Feb 13, 2026

Greptile Overview

Greptile Summary

Replaced the global @import 'tailwindcss/preflight.css' with a manually scoped version wrapped in :where([data-yv-sdk]). This prevents Tailwind's CSS resets (margins, padding, heading sizes, list styles, etc.) from affecting consumer apps while preserving the resets within SDK components.

Key changes:

  • Removed global preflight import that was resetting styles on all DOM elements
  • Added 150 lines of scoped preflight CSS targeting only [data-yv-sdk] elements
  • Used :where() pseudo-class to keep specificity at zero, allowing consumer styles to override when needed
  • All SDK components already render with data-yv-sdk attribute, so no component changes required

Analysis:
The approach is sound. All public-facing SDK components (BibleReader, VerseOfTheDay, YouVersionAuthButton, BibleVersionPicker, BibleChapterPicker, BibleWidgetView, Verse) render root elements with data-yv-sdk. Primitive UI components (Button, Input, etc.) are always nested within these roots, so they inherit the scoped resets correctly.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is well-executed and addresses a critical CSS scoping issue. The manually scoped preflight CSS is a standard Tailwind pattern, all SDK components already use the data-yv-sdk attribute, and the :where() wrapper ensures zero specificity. The changeset follows unified versioning requirements by bumping all three packages. No logic changes, security risks, or breaking changes.
  • No files require special attention

Important Files Changed

Filename Overview
packages/ui/src/styles/global.css Replaced global preflight import with manually scoped preflight CSS wrapped in :where([data-yv-sdk]) to prevent SDK styles from affecting consumer apps
.changeset/scope-preflight-css.md Changeset properly bumps all three packages (ui, core, hooks) as patch versions per unified versioning requirement

Last reviewed commit: 7e248f6

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.
@cameronapak
Copy link
Collaborator Author

@greptileai, update the description of this PR and then re-review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@cameronapak cameronapak requested a review from bmanquen February 13, 2026 17:55
@cameronapak cameronapak changed the title fix: scope Tailwind preflight CSS to SDK components only YPE-1320: scope Tailwind preflight CSS to SDK components only Feb 13, 2026
@cameronapak cameronapak self-assigned this Feb 13, 2026
@cameronapak cameronapak added the bug Something isn't working label Feb 13, 2026
bmanquen
bmanquen previously approved these changes Feb 13, 2026
Copy link
Collaborator

@bmanquen bmanquen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bmanquen bmanquen self-requested a review February 13, 2026 22:12
@bmanquen bmanquen dismissed their stale review February 13, 2026 22:12

See comment above.

@bmanquen
Copy link
Collaborator

bmanquen commented Feb 14, 2026

I just saw that this is causing font family issues in the chapter and versions pickers.

image image

@cameronapak
Copy link
Collaborator Author

This has been addressed and fixed @bmanquen !

CleanShot 2026-02-16 at 12 01 52@2x

@cameronapak cameronapak merged commit ee7a69b into main Feb 16, 2026
5 checks passed
@cameronapak cameronapak deleted the cam/css-issues-v3 branch February 16, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants