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
  80f64279_dc28_709a_aad4_02bea029c935["isVariableUsed()"]
  ec867cf3_916b_0d16_65ec_c715e69fee03["optimizeAst()"]
  ec867cf3_916b_0d16_65ec_c715e69fee03 -->|calls| 80f64279_dc28_709a_aad4_02bea029c935
  3ba19013_498f_3c9b_5c44_0eb24efc4394["add()"]
  80f64279_dc28_709a_aad4_02bea029c935 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  be7a0843_7490_00b8_ff59_a27552035f10["getOptions()"]
  80f64279_dc28_709a_aad4_02bea029c935 -->|calls| be7a0843_7490_00b8_ff59_a27552035f10
  4cd99e59_ac1e_2a1f_0946_33cc1afd2532["get()"]
  80f64279_dc28_709a_aad4_02bea029c935 -->|calls| 4cd99e59_ac1e_2a1f_0946_33cc1afd2532
  style 80f64279_dc28_709a_aad4_02bea029c935 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
}

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