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
  8e2c4c54_aa31_b4ac_9cd4_b3d16178fc76["resolveThemeColor()"]
  ffde8eb7_7def_91ee_918c_be4f250f76a2["utilities.ts"]
  8e2c4c54_aa31_b4ac_9cd4_b3d16178fc76 -->|defined in| ffde8eb7_7def_91ee_918c_be4f250f76a2
  08526c9b_2b40_0b09_3dbc_69449eef6643["resolve()"]
  8e2c4c54_aa31_b4ac_9cd4_b3d16178fc76 -->|calls| 08526c9b_2b40_0b09_3dbc_69449eef6643
  dfcc5bf9_96ac_0c12_9e9e_7288796d1837["asColor()"]
  8e2c4c54_aa31_b4ac_9cd4_b3d16178fc76 -->|calls| dfcc5bf9_96ac_0c12_9e9e_7288796d1837
  style 8e2c4c54_aa31_b4ac_9cd4_b3d16178fc76 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