Home / Function/ migrateVariantsDirective() — tailwindcss Function Reference

migrateVariantsDirective() — tailwindcss Function Reference

Architecture documentation for the migrateVariantsDirective() function in migrate-variants-directive.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  1368c334_8c0c_490a_01a7_3b36d137368a["migrateVariantsDirective()"]
  8403a095_a391_8879_03a7_dca5d41871c7["migrate-variants-directive.ts"]
  1368c334_8c0c_490a_01a7_3b36d137368a -->|defined in| 8403a095_a391_8879_03a7_dca5d41871c7
  d9bea0e2_8cac_1f78_0da8_1b218d06e7f5["migrate()"]
  d9bea0e2_8cac_1f78_0da8_1b218d06e7f5 -->|calls| 1368c334_8c0c_490a_01a7_3b36d137368a
  1be562b7_fe23_7e22_03ec_31b3d101e5e5["migrateContents()"]
  1be562b7_fe23_7e22_03ec_31b3d101e5e5 -->|calls| 1368c334_8c0c_490a_01a7_3b36d137368a
  style 1368c334_8c0c_490a_01a7_3b36d137368a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/codemods/css/migrate-variants-directive.ts lines 3–35

export function migrateVariantsDirective(): Plugin {
  function migrate(root: Root) {
    root.walkAtRules('variants', (node) => {
      // Migrate `@variants` to `@utility` because `@variants` make the classes
      // an actual utility.
      // ```css
      // @variants hover {
      //   .foo {}
      // }
      // ```
      //
      // Means that you can do this in your HTML:
      // ```html
      // <div class="focus:foo"></div>
      // ```
      //
      // Notice the `focus:`, even though we _only_ configured the `hover`
      // variant.
      //
      // This means that we can convert it to an `@layer utilities` rule. Later,
      // this will get converted to an `@utility` rule.
      if (node.name === 'variants') {
        node.name = 'layer'
        node.params = 'utilities'
      }
    })
  }

  return {
    postcssPlugin: '@tailwindcss/upgrade/migrate-variants-directive',
    OnceExit: migrate,
  }
}

Subdomains

Frequently Asked Questions

What does migrateVariantsDirective() do?
migrateVariantsDirective() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-upgrade/src/codemods/css/migrate-variants-directive.ts.
Where is migrateVariantsDirective() defined?
migrateVariantsDirective() is defined in packages/@tailwindcss-upgrade/src/codemods/css/migrate-variants-directive.ts at line 3.
What calls migrateVariantsDirective()?
migrateVariantsDirective() is called by 2 function(s): migrate, migrateContents.

Analyze Your Own Codebase

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

Try Supermodel Free