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

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

Analyze Your Own Codebase

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

Try Supermodel Free