Skip to content

[v3.4.x] Custom variant for elements that are not descendants of @container breaks #13370

Closed Answered by hellovietduc
hellovietduc asked this question in Help
Discussion options

You must be logged in to vote

Because the nature of this variant, -@ needs to be the last variant so it can capture the full selector and put it in the :not() pseudo-class.

I finally made it work in 3.4.4:

/**
 * Register -@ variant
 * Use this to match elements that don't have a container ancestor.
 * This variant must be put last so it can capture the full selector.
 * @example tablet-portrait:-@:m-0
 * @output
 * ```css
 * @media (min-width: 744px) {
 *   .tablet-portrait\:-\@\:m-0:not([class*="@container"] .tablet-portrait\:-\@\:m-0) {
 *     margin: 0px;
 *   }
 * }
 * ```
 */
addVariant('-@', ({ modifySelectors }) => {
  modifySelectors(() => `&:not([class*="@container"] &)`)
})

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@wongjn
Comment options

@hellovietduc
Comment options

Answer selected by hellovietduc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants