Home / Function/ mergeThemeExtension() — tailwindcss Function Reference

mergeThemeExtension() — tailwindcss Function Reference

Architecture documentation for the mergeThemeExtension() function in resolve-config.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  d2f80a98_6e83_ca64_8fb7_495e0941e9e7["mergeThemeExtension()"]
  cad44155_17aa_e1d6_081a_8f3b4f06bcde["resolve-config.ts"]
  d2f80a98_6e83_ca64_8fb7_495e0941e9e7 -->|defined in| cad44155_17aa_e1d6_081a_8f3b4f06bcde
  69358a0d_01e9_2bb6_df8d_9a5e9a5c6306["isPlainObject()"]
  d2f80a98_6e83_ca64_8fb7_495e0941e9e7 -->|calls| 69358a0d_01e9_2bb6_df8d_9a5e9a5c6306
  style d2f80a98_6e83_ca64_8fb7_495e0941e9e7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/compat/config/resolve-config.ts lines 102–128

export function mergeThemeExtension(
  themeValue: ThemeValue | ThemeValue[],
  extensionValue: ThemeValue | ThemeValue[],
) {
  // When we have an array of objects, we do want to merge it
  if (Array.isArray(themeValue) && isPlainObject(themeValue[0])) {
    return themeValue.concat(extensionValue)
  }

  // When the incoming value is an array, and the existing config is an object,
  // prepend the existing object
  if (
    Array.isArray(extensionValue) &&
    isPlainObject(extensionValue[0]) &&
    isPlainObject(themeValue)
  ) {
    return [themeValue, ...extensionValue]
  }

  // Override arrays (for example for font-families, box-shadows, ...)
  if (Array.isArray(extensionValue)) {
    return extensionValue
  }

  // Execute default behavior
  return undefined
}

Domain

Subdomains

Frequently Asked Questions

What does mergeThemeExtension() do?
mergeThemeExtension() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/compat/config/resolve-config.ts.
Where is mergeThemeExtension() defined?
mergeThemeExtension() is defined in packages/tailwindcss/src/compat/config/resolve-config.ts at line 102.
What does mergeThemeExtension() call?
mergeThemeExtension() calls 1 function(s): isPlainObject.

Analyze Your Own Codebase

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

Try Supermodel Free