Skip to content

Conversation

@wcole1-godaddy
Copy link
Contributor

Summary

Add a second CSS export (styles-tailwind.css) for projects that already have Tailwind installed.

Problem

When consumers with Tailwind v3 import @godaddy/react/styles.css, they get:

@layer base is used but no matching @tailwind base directive is present

This happens because Tailwind v3's PostCSS plugin sees the compiled @layer base block and expects a corresponding @tailwind base directive.

Solution

Ship two CSS exports:

Export Use Case
@godaddy/react/styles.css Standalone (no Tailwind) - includes full preflight
@godaddy/react/styles-tailwind.css Tailwind projects - excludes base layer

The tailwind version uses:

@import "tailwindcss/theme" layer(theme);
@import "tailwindcss/utilities" source(none);

This includes theme mappings and utilities but not the base/preflight layer.

Usage

// For Tailwind projects
import '@godaddy/react/styles-tailwind.css';

// For non-Tailwind projects  
import '@godaddy/react/styles.css';

Notes

  • Import from JS, not inside your Tailwind CSS file
  • Import after your app's Tailwind CSS for correct cascade order
  • Theme customization via --gd-* CSS variables

- Add styles-tailwind.css export for projects that already have Tailwind
- This version excludes @layer base to avoid conflicts with Tailwind v3's
  PostCSS plugin which errors on '@layer base without @tailwind base'
- Original styles.css remains for standalone use (includes full preflight)
- Update build script to generate both CSS bundles
- Update Next.js example to use styles-tailwind.css

Amp-Thread-ID: https://ampcode.com/threads/T-7af49944-d367-4aa2-bac3-60864e5009fa
Co-authored-by: Amp <[email protected]>
@wcole1-godaddy wcole1-godaddy requested a review from a team as a code owner November 26, 2025 01:15
@changeset-bot
Copy link

changeset-bot bot commented Nov 26, 2025

🦋 Changeset detected

Latest commit: 0e69461

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

This PR includes changesets to release 2 packages
Name Type
@godaddy/react 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

@wcole1-godaddy wcole1-godaddy merged commit b17602f into main Nov 26, 2025
3 checks passed
@wcole1-godaddy wcole1-godaddy deleted the feat/tailwind-v3-v4-compatibility branch November 26, 2025 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants