Home / Function/ isVariableUsed() — tailwindcss Function Reference

isVariableUsed() — tailwindcss Function Reference

Architecture documentation for the isVariableUsed() function in ast.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  eebd49be_6bf6_0e23_60fa_4e12a1151233["isVariableUsed()"]
  a6e11c3d_c962_0a65_d91f_6fbe955cf4f0["optimizeAst()"]
  a6e11c3d_c962_0a65_d91f_6fbe955cf4f0 -->|calls| eebd49be_6bf6_0e23_60fa_4e12a1151233
  24d95be4_356f_a1f9_9702_2a4f413db0f5["add()"]
  eebd49be_6bf6_0e23_60fa_4e12a1151233 -->|calls| 24d95be4_356f_a1f9_9702_2a4f413db0f5
  c8189e3c_da83_8664_ad35_d7e6af6bc483["getOptions()"]
  eebd49be_6bf6_0e23_60fa_4e12a1151233 -->|calls| c8189e3c_da83_8664_ad35_d7e6af6bc483
  3e179907_5f92_f314_14dc_f61853c74cad["get()"]
  eebd49be_6bf6_0e23_60fa_4e12a1151233 -->|calls| 3e179907_5f92_f314_14dc_f61853c74cad
  style eebd49be_6bf6_0e23_60fa_4e12a1151233 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/ast.ts lines 903–929

function isVariableUsed(
  variable: string,
  theme: Theme,
  variableDependencies: Map<string, Set<string>>,
  alreadySeenVariables: Set<string> = new Set(),
): boolean {
  // Break recursions when visiting a variable twice
  if (alreadySeenVariables.has(variable)) {
    return true
  } else {
    alreadySeenVariables.add(variable)
  }

  let options = theme.getOptions(variable)
  if (options & (ThemeOptions.STATIC | ThemeOptions.USED)) {
    return true
  } else {
    let dependencies = variableDependencies.get(variable) ?? []
    for (let dependency of dependencies) {
      if (isVariableUsed(dependency, theme, variableDependencies, alreadySeenVariables)) {
        return true
      }
    }
  }

  return false
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does isVariableUsed() do?
isVariableUsed() is a function in the tailwindcss codebase.
What does isVariableUsed() call?
isVariableUsed() calls 3 function(s): add, get, getOptions.
What calls isVariableUsed()?
isVariableUsed() is called by 1 function(s): optimizeAst.

Analyze Your Own Codebase

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

Try Supermodel Free