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
  78c8b616_5d61_b046_efc3_274ea6b73960["mergeThemeExtension()"]
  9b5d2e3d_392e_c654_c350_1352ed70f5e8["resolve-config.ts"]
  78c8b616_5d61_b046_efc3_274ea6b73960 -->|defined in| 9b5d2e3d_392e_c654_c350_1352ed70f5e8
  2dacf643_3af3_ced5_8784_dc1356541f05["isPlainObject()"]
  78c8b616_5d61_b046_efc3_274ea6b73960 -->|calls| 2dacf643_3af3_ced5_8784_dc1356541f05
  style 78c8b616_5d61_b046_efc3_274ea6b73960 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
}

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