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
  314b128c_0d3c_81a7_f2fa_d11e9edcc320["alphaReplacedShadowProperties()"]
  2bc6f8eb_6339_d09c_79df_e9025a479c97["utilities.ts"]
  314b128c_0d3c_81a7_f2fa_d11e9edcc320 -->|defined in| 2bc6f8eb_6339_d09c_79df_e9025a479c97
  5bac8829_51ba_4cde_5b5b_16bf890de6ec["replaceShadowColors()"]
  314b128c_0d3c_81a7_f2fa_d11e9edcc320 -->|calls| 5bac8829_51ba_4cde_5b5b_16bf890de6ec
  b71e300f_d366_e92d_f71f_413f7ee24e95["withAlpha()"]
  314b128c_0d3c_81a7_f2fa_d11e9edcc320 -->|calls| b71e300f_d366_e92d_f71f_413f7ee24e95
  3f0c8c99_3ead_e51c_3ce2_4cae3716184f["replaceAlpha()"]
  314b128c_0d3c_81a7_f2fa_d11e9edcc320 -->|calls| 3f0c8c99_3ead_e51c_3ce2_4cae3716184f
  f712ed47_45d4_4e5a_dd73_fdefa1da71da["segment()"]
  314b128c_0d3c_81a7_f2fa_d11e9edcc320 -->|calls| f712ed47_45d4_4e5a_dd73_fdefa1da71da
  c203f636_607a_d332_b4c5_6a40c108f778["decl()"]
  314b128c_0d3c_81a7_f2fa_d11e9edcc320 -->|calls| c203f636_607a_d332_b4c5_6a40c108f778
  66319c06_7c38_f9ea_4bf0_2a0e18bac1a4["rule()"]
  314b128c_0d3c_81a7_f2fa_d11e9edcc320 -->|calls| 66319c06_7c38_f9ea_4bf0_2a0e18bac1a4
  style 314b128c_0d3c_81a7_f2fa_d11e9edcc320 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, defined in packages/tailwindcss/src/utilities.ts.
Where is alphaReplacedShadowProperties() defined?
alphaReplacedShadowProperties() is defined in packages/tailwindcss/src/utilities.ts at line 6447.
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