Home / Function/ themeToVarUtility() — tailwindcss Function Reference

themeToVarUtility() — tailwindcss Function Reference

Architecture documentation for the themeToVarUtility() function in canonicalize-candidates.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  f8aa1ce2_bb66_012e_f332_ef87271ef564["themeToVarUtility()"]
  7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e["canonicalize-candidates.ts"]
  f8aa1ce2_bb66_012e_f332_ef87271ef564 -->|defined in| 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e
  style f8aa1ce2_bb66_012e_f332_ef87271ef564 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/canonicalize-candidates.ts lines 583–613

function themeToVarUtility(candidate: Candidate, options: InternalCanonicalizeOptions): Candidate {
  let convert = options.designSystem.storage[CONVERTER_KEY]

  if (candidate.kind === 'arbitrary') {
    let [newValue, modifier] = convert(
      candidate.value,
      candidate.modifier === null ? Convert.MigrateModifier : Convert.All,
    )
    if (newValue !== candidate.value) {
      candidate.value = newValue

      if (modifier !== null) {
        candidate.modifier = modifier
      }
    }
  } else if (candidate.kind === 'functional' && candidate.value?.kind === 'arbitrary') {
    let [newValue, modifier] = convert(
      candidate.value.value,
      candidate.modifier === null ? Convert.MigrateModifier : Convert.All,
    )
    if (newValue !== candidate.value.value) {
      candidate.value.value = newValue

      if (modifier !== null) {
        candidate.modifier = modifier
      }
    }
  }

  return candidate
}

Subdomains

Frequently Asked Questions

What does themeToVarUtility() do?
themeToVarUtility() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/canonicalize-candidates.ts.
Where is themeToVarUtility() defined?
themeToVarUtility() is defined in packages/tailwindcss/src/canonicalize-candidates.ts at line 583.

Analyze Your Own Codebase

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

Try Supermodel Free