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
  6540f887_c4fb_c66b_6dde_c34158fdac0c["mergeThemeExtension()"]
  44ea0add_f78b_a0da_1851_38236796bf32["isPlainObject()"]
  6540f887_c4fb_c66b_6dde_c34158fdac0c -->|calls| 44ea0add_f78b_a0da_1851_38236796bf32
  style 6540f887_c4fb_c66b_6dde_c34158fdac0c 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.
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