injectVar() — tailwindcss Function Reference
Architecture documentation for the injectVar() function in migrate-automatic-var-injection.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 343db49c_7d28_8ddb_aab2_f4cb835639a7["injectVar()"] d475bcf1_b109_d714_cc32_55d5655282ec["migrate-automatic-var-injection.ts"] 343db49c_7d28_8ddb_aab2_f4cb835639a7 -->|defined in| d475bcf1_b109_d714_cc32_55d5655282ec aeb7589b_9d5b_312e_4558_4df754cbb905["migrateAutomaticVarInjection()"] aeb7589b_9d5b_312e_4558_4df754cbb905 -->|calls| 343db49c_7d28_8ddb_aab2_f4cb835639a7 d77b4c83_759b_998e_e087_dabe3109d95c["injectVarIntoVariant()"] d77b4c83_759b_998e_e087_dabe3109d95c -->|calls| 343db49c_7d28_8ddb_aab2_f4cb835639a7 2d6c8361_96d8_df0d_ca51_c62f179fdc73["parse()"] 343db49c_7d28_8ddb_aab2_f4cb835639a7 -->|calls| 2d6c8361_96d8_df0d_ca51_c62f179fdc73 style 343db49c_7d28_8ddb_aab2_f4cb835639a7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-upgrade/src/codemods/template/migrate-automatic-var-injection.ts lines 76–101
function injectVar(value: string): { value: string; didChange: boolean } {
let didChange = false
if (value.startsWith('--')) {
// E.g.:
//
// - `--my-color` → `var(--my-color)` Convert variable
// - `--my-color,red` → `var(--my-color,red)` Convert variable with fallback
// - `--theme(color.red)` → `--theme(color.red)` Do not convert functions
//
if (
// No `(` definitely means there is no function
!value.includes('(') ||
// There could be a function call in the fallback value, but it cannot be
// top-level, so we can safely check the first part
ValueParser.parse(value)[0]?.kind !== 'function'
) {
value = `var(${value})`
didChange = true
}
} else if (value.startsWith(' --')) {
value = value.slice(1)
didChange = true
}
return { value, didChange }
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does injectVar() do?
injectVar() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-upgrade/src/codemods/template/migrate-automatic-var-injection.ts.
Where is injectVar() defined?
injectVar() is defined in packages/@tailwindcss-upgrade/src/codemods/template/migrate-automatic-var-injection.ts at line 76.
What does injectVar() call?
injectVar() calls 1 function(s): parse.
What calls injectVar()?
injectVar() is called by 2 function(s): injectVarIntoVariant, migrateAutomaticVarInjection.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free