Home / Function/ resolveThemeColor() — tailwindcss Function Reference

resolveThemeColor() — tailwindcss Function Reference

Architecture documentation for the resolveThemeColor() function in utilities.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  3c29461b_66f7_8e1b_36c1_73009733fbe6["resolveThemeColor()"]
  2bc6f8eb_6339_d09c_79df_e9025a479c97["utilities.ts"]
  3c29461b_66f7_8e1b_36c1_73009733fbe6 -->|defined in| 2bc6f8eb_6339_d09c_79df_e9025a479c97
  71290460_1a88_ed12_99a9_992d30e78865["resolve()"]
  3c29461b_66f7_8e1b_36c1_73009733fbe6 -->|calls| 71290460_1a88_ed12_99a9_992d30e78865
  862a63f1_955e_2605_54a1_0a25a475b9e9["asColor()"]
  3c29461b_66f7_8e1b_36c1_73009733fbe6 -->|calls| 862a63f1_955e_2605_54a1_0a25a475b9e9
  style 3c29461b_66f7_8e1b_36c1_73009733fbe6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/utilities.ts lines 243–280

function resolveThemeColor<T extends ThemeKey>(
  candidate: Extract<Candidate, { kind: 'functional' }>,
  theme: Theme,
  themeKeys: T[],
) {
  if (process.env.NODE_ENV === 'test') {
    if (!candidate.value) {
      throw new Error('resolveThemeColor must be called with a named candidate')
    }

    if (candidate.value.kind !== 'named') {
      throw new Error('resolveThemeColor must be called with a named value')
    }
  }

  let value: string | null = null

  switch (candidate.value!.value) {
    case 'inherit': {
      value = 'inherit'
      break
    }
    case 'transparent': {
      value = 'transparent'
      break
    }
    case 'current': {
      value = 'currentcolor'
      break
    }
    default: {
      value = theme.resolve(candidate.value!.value, themeKeys)
      break
    }
  }

  return value ? asColor(value, candidate.modifier, theme) : null
}

Domain

Subdomains

Frequently Asked Questions

What does resolveThemeColor() do?
resolveThemeColor() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/utilities.ts.
Where is resolveThemeColor() defined?
resolveThemeColor() is defined in packages/tailwindcss/src/utilities.ts at line 243.
What does resolveThemeColor() call?
resolveThemeColor() calls 2 function(s): asColor, resolve.

Analyze Your Own Codebase

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

Try Supermodel Free