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
  7d010542_1cda_a540_2ca4_161f665333e4["resolveThemeColor()"]
  fb0edc12_e3ff_ec56_83b9_8cf4f1b5f8e5["resolve()"]
  7d010542_1cda_a540_2ca4_161f665333e4 -->|calls| fb0edc12_e3ff_ec56_83b9_8cf4f1b5f8e5
  ce40bfca_da92_1ec0_b286_244e5002cb7e["asColor()"]
  7d010542_1cda_a540_2ca4_161f665333e4 -->|calls| ce40bfca_da92_1ec0_b286_244e5002cb7e
  style 7d010542_1cda_a540_2ca4_161f665333e4 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
}

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