Home / Function/ alphaReplacedShadowProperties() — tailwindcss Function Reference

alphaReplacedShadowProperties() — tailwindcss Function Reference

Architecture documentation for the alphaReplacedShadowProperties() function in utilities.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  537db6f9_ffa5_12bf_0cec_283e545c7822["alphaReplacedShadowProperties()"]
  ee6a51e8_b2d4_4e8c_e8b0_55eae5041272["replaceShadowColors()"]
  537db6f9_ffa5_12bf_0cec_283e545c7822 -->|calls| ee6a51e8_b2d4_4e8c_e8b0_55eae5041272
  8412278d_9a59_ef02_8a3b_9c8e8ab65674["withAlpha()"]
  537db6f9_ffa5_12bf_0cec_283e545c7822 -->|calls| 8412278d_9a59_ef02_8a3b_9c8e8ab65674
  b7205c5d_8a1a_a50a_229f_7133a6a9c980["replaceAlpha()"]
  537db6f9_ffa5_12bf_0cec_283e545c7822 -->|calls| b7205c5d_8a1a_a50a_229f_7133a6a9c980
  03b8d706_a876_a776_0056_186ced5d6067["segment()"]
  537db6f9_ffa5_12bf_0cec_283e545c7822 -->|calls| 03b8d706_a876_a776_0056_186ced5d6067
  47ef7bd7_b959_59c4_dbd1_328f35d7cd89["decl()"]
  537db6f9_ffa5_12bf_0cec_283e545c7822 -->|calls| 47ef7bd7_b959_59c4_dbd1_328f35d7cd89
  f4f92a3d_c13e_a751_8402_451ffa4c772f["rule()"]
  537db6f9_ffa5_12bf_0cec_283e545c7822 -->|calls| f4f92a3d_c13e_a751_8402_451ffa4c772f
  style 537db6f9_ffa5_12bf_0cec_283e545c7822 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/utilities.ts lines 6447–6491

function alphaReplacedShadowProperties(
  property: string,
  value: string,
  alpha: string | null | undefined,
  varInjector: (color: string) => string,
  prefix: string = '',
): AstNode[] {
  let requiresFallback = false
  let replacedValue = replaceShadowColors(value, (color) => {
    if (alpha == null) {
      return varInjector(color)
    }

    // When the input is currentcolor, we use our existing `color-mix(…)` approach to increase
    // browser support. Note that the fallback of this is handled more generically in
    // post-processing.
    if (color.startsWith('current')) {
      return varInjector(withAlpha(color, alpha))
    }

    // If any dynamic values are needed for the relative color syntax, we need to insert a
    // replacement as lightningcss won't be able to resolve them statically.
    if (color.startsWith('var(') || alpha.startsWith('var(')) {
      requiresFallback = true
    }

    return varInjector(replaceAlpha(color, alpha))
  })

  function applyPrefix(x: string) {
    if (!prefix) return x
    return segment(x, ',')
      .map((value) => prefix.trim() + ' ' + value.trim())
      .join(', ')
  }

  if (requiresFallback) {
    return [
      decl(property, applyPrefix(replaceShadowColors(value, varInjector))),
      rule('@supports (color: lab(from red l a b))', [decl(property, applyPrefix(replacedValue))]),
    ]
  } else {
    return [decl(property, applyPrefix(replacedValue))]
  }
}

Domain

Subdomains

Frequently Asked Questions

What does alphaReplacedShadowProperties() do?
alphaReplacedShadowProperties() is a function in the tailwindcss codebase.
What does alphaReplacedShadowProperties() call?
alphaReplacedShadowProperties() calls 6 function(s): decl, replaceAlpha, replaceShadowColors, rule, segment, withAlpha.

Analyze Your Own Codebase

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

Try Supermodel Free