Skip to content

fix(styles): skip :has() selectors in createStyleMap - #11585

Open
dipakpatil025 wants to merge 2 commits into
shadcn-ui:mainfrom
dipakpatil025:fix/style-map-skip-has-selectors
Open

fix(styles): skip :has() selectors in createStyleMap#11585
dipakpatil025 wants to merge 2 commits into
shadcn-ui:mainfrom
dipakpatil025:fix/style-map-skip-has-selectors

Conversation

@dipakpatil025

Copy link
Copy Markdown

What

Fixes #11584

createStyleMap was incorrectly including classes from :has() selectors
in the style map. This caused transformStyleMap to inline those classes
unconditionally into every component instance.

For example, style-vega.css has:

.cn-card-content {
  @apply px-(--card-spacing);
}
.cn-card-content:has(> [data-slot=questionnaire-choices]) {
  @apply flex flex-col gap-3;
}

The CLI was generating:

className={cn("flex flex-col gap-3 px-(--card-spacing)", className)}

instead of the correct:

className={cn("px-(--card-spacing)", className)}

Why

:has() selectors are conditional — they apply only when the element
contains specific children. They cannot be represented as a static Tailwind
class name. The fix skips any selector containing a :has pseudo-class
during style map construction so the styles remain in CSS where the
condition is respected.

Changes

- packages/shadcn/src/styles/create-style-map.ts — skip :has() selectors
- packages/shadcn/src/styles/create-style-map.test.ts — regression test

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@dipak-patil-noovosoft is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Can you sign the commits please? See https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits. Thank you.

@dipakpatil025
dipakpatil025 force-pushed the fix/style-map-skip-has-selectors branch from 802afc1 to 791ad47 Compare August 21, 2026 17:42
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.

[bug]: Vega CardContent styles are incorrectly generated without the original :has() condition

1 participant