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
  7fde493f_fce8_21db_d666_1cc635b91c73["alphaReplacedShadowProperties()"]
  ffde8eb7_7def_91ee_918c_be4f250f76a2["utilities.ts"]
  7fde493f_fce8_21db_d666_1cc635b91c73 -->|defined in| ffde8eb7_7def_91ee_918c_be4f250f76a2
  da3c2484_686d_b298_523c_750c3035414c["replaceShadowColors()"]
  7fde493f_fce8_21db_d666_1cc635b91c73 -->|calls| da3c2484_686d_b298_523c_750c3035414c
  2e8f6051_b6e8_4985_14e1_e11717a8d2ab["withAlpha()"]
  7fde493f_fce8_21db_d666_1cc635b91c73 -->|calls| 2e8f6051_b6e8_4985_14e1_e11717a8d2ab
  c9298b5e_9901_b387_90f5_20565f550298["replaceAlpha()"]
  7fde493f_fce8_21db_d666_1cc635b91c73 -->|calls| c9298b5e_9901_b387_90f5_20565f550298
  c58cbb33_f3cc_0b4f_844a_15bf66a1dc61["segment()"]
  7fde493f_fce8_21db_d666_1cc635b91c73 -->|calls| c58cbb33_f3cc_0b4f_844a_15bf66a1dc61
  1369a6dc_e395_347d_5d24_b88e22c5446d["decl()"]
  7fde493f_fce8_21db_d666_1cc635b91c73 -->|calls| 1369a6dc_e395_347d_5d24_b88e22c5446d
  085cf56e_8188_afb1_04da_5ccd0fb7babc["rule()"]
  7fde493f_fce8_21db_d666_1cc635b91c73 -->|calls| 085cf56e_8188_afb1_04da_5ccd0fb7babc
  style 7fde493f_fce8_21db_d666_1cc635b91c73 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