replaceShadowColors() — tailwindcss Function Reference
Architecture documentation for the replaceShadowColors() function in replace-shadow-colors.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD da3c2484_686d_b298_523c_750c3035414c["replaceShadowColors()"] 5b848d60_40d3_e198_b396_38cb0e6eeec4["replace-shadow-colors.ts"] da3c2484_686d_b298_523c_750c3035414c -->|defined in| 5b848d60_40d3_e198_b396_38cb0e6eeec4 7fde493f_fce8_21db_d666_1cc635b91c73["alphaReplacedShadowProperties()"] 7fde493f_fce8_21db_d666_1cc635b91c73 -->|calls| da3c2484_686d_b298_523c_750c3035414c 2fb3c38b_1032_ddeb_49cf_fcc482602e23["alphaReplacedDropShadowProperties()"] 2fb3c38b_1032_ddeb_49cf_fcc482602e23 -->|calls| da3c2484_686d_b298_523c_750c3035414c c58cbb33_f3cc_0b4f_844a_15bf66a1dc61["segment()"] da3c2484_686d_b298_523c_750c3035414c -->|calls| c58cbb33_f3cc_0b4f_844a_15bf66a1dc61 style da3c2484_686d_b298_523c_750c3035414c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/utils/replace-shadow-colors.ts lines 6–48
export function replaceShadowColors(input: string, replacement: (color: string) => string) {
let shadows = segment(input, ',').map((shadow) => {
shadow = shadow.trim()
let parts = segment(shadow, ' ').filter((part) => part.trim() !== '')
let color = null
let offsetX = null
let offsetY = null
for (let part of parts) {
if (KEYWORDS.has(part)) {
continue
} else if (LENGTH.test(part)) {
if (offsetX === null) {
offsetX = part
} else if (offsetY === null) {
offsetY = part
}
// Reset index, since the regex is stateful.
LENGTH.lastIndex = 0
} else if (color === null) {
color = part
}
}
// If the x and y offsets were not detected, the shadow is either invalid or
// using a variable to represent more than one field in the shadow value, so
// we can't know what to replace.
if (offsetX === null || offsetY === null) return shadow
let replacementColor = replacement(color ?? 'currentcolor')
if (color !== null) {
// If a color was found, replace the color.
return shadow.replace(color, replacementColor)
}
// If no color was found, assume the shadow is relying on the browser
// default shadow color and append the replacement color.
return `${shadow} ${replacementColor}`
})
return shadows.join(', ')
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does replaceShadowColors() do?
replaceShadowColors() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/utils/replace-shadow-colors.ts.
Where is replaceShadowColors() defined?
replaceShadowColors() is defined in packages/tailwindcss/src/utils/replace-shadow-colors.ts at line 6.
What does replaceShadowColors() call?
replaceShadowColors() calls 1 function(s): segment.
What calls replaceShadowColors()?
replaceShadowColors() is called by 2 function(s): alphaReplacedDropShadowProperties, alphaReplacedShadowProperties.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free