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
  7b2cecd9_ff4e_832b_e6dd_26768f0757c1["resolveThemeColor()"]
  ce52b228_a53f_22f4_e753_5d926d778157["resolve()"]
  7b2cecd9_ff4e_832b_e6dd_26768f0757c1 -->|calls| ce52b228_a53f_22f4_e753_5d926d778157
  8d5e20f1_5091_5002_1260_1f08298c4254["asColor()"]
  7b2cecd9_ff4e_832b_e6dd_26768f0757c1 -->|calls| 8d5e20f1_5091_5002_1260_1f08298c4254
  style 7b2cecd9_ff4e_832b_e6dd_26768f0757c1 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.
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