Home / Function/ compoundsForSelectors() — tailwindcss Function Reference

compoundsForSelectors() — tailwindcss Function Reference

Architecture documentation for the compoundsForSelectors() function in variants.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  828655d7_fafb_f7a4_ba36_e6b356a78fbc["compoundsForSelectors()"]
  ad196438_55f7_af7b_1604_1d75c1c27d8e["buildPluginApi()"]
  ad196438_55f7_af7b_1604_1d75c1c27d8e -->|calls| 828655d7_fafb_f7a4_ba36_e6b356a78fbc
  26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c["parseCss()"]
  26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c -->|calls| 828655d7_fafb_f7a4_ba36_e6b356a78fbc
  43c6ae59_76f1_6f53_dfa2_f3151fd259d1["fromAst()"]
  43c6ae59_76f1_6f53_dfa2_f3151fd259d1 -->|calls| 828655d7_fafb_f7a4_ba36_e6b356a78fbc
  322c45ea_3835_3229_6b47_7ac91365ee73["compoundsWith()"]
  322c45ea_3835_3229_6b47_7ac91365ee73 -->|calls| 828655d7_fafb_f7a4_ba36_e6b356a78fbc
  7c96535c_85cb_d6bf_efe4_875fba595c4f["createVariants()"]
  7c96535c_85cb_d6bf_efe4_875fba595c4f -->|calls| 828655d7_fafb_f7a4_ba36_e6b356a78fbc
  style 828655d7_fafb_f7a4_ba36_e6b356a78fbc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/variants.ts lines 319–346

export function compoundsForSelectors(selectors: string[]) {
  let compounds = Compounds.Never

  for (let sel of selectors) {
    if (sel[0] === '@') {
      // Non-conditional at-rules are present so we can't compound
      if (
        !sel.startsWith('@media') &&
        !sel.startsWith('@supports') &&
        !sel.startsWith('@container')
      ) {
        return Compounds.Never
      }

      compounds |= Compounds.AtRules
      continue
    }

    // Pseudo-elements are present so we can't compound
    if (sel.includes('::')) {
      return Compounds.Never
    }

    compounds |= Compounds.StyleRules
  }

  return compounds
}

Subdomains

Frequently Asked Questions

What does compoundsForSelectors() do?
compoundsForSelectors() is a function in the tailwindcss codebase.
What calls compoundsForSelectors()?
compoundsForSelectors() is called by 5 function(s): buildPluginApi, compoundsWith, createVariants, fromAst, parseCss.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free