substituteAtVariant() — tailwindcss Function Reference
Architecture documentation for the substituteAtVariant() function in variants.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 0ec6110b_085e_e69b_cc4a_37d966dc5ace["substituteAtVariant()"] db9eae47_695c_23c3_68bd_bae5bb363efe["variants.ts"] 0ec6110b_085e_e69b_cc4a_37d966dc5ace -->|defined in| db9eae47_695c_23c3_68bd_bae5bb363efe 9b965fd7_d8e9_0b43_cd5d_c9294ab598ed["buildDesignSystem()"] 9b965fd7_d8e9_0b43_cd5d_c9294ab598ed -->|calls| 0ec6110b_085e_e69b_cc4a_37d966dc5ace 3970218d_3d6c_e455_87cc_45b4a094f0e9["parseCss()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 0ec6110b_085e_e69b_cc4a_37d966dc5ace 34338b14_fec6_6308_0fd7_15af8d4da01b["fromAst()"] 34338b14_fec6_6308_0fd7_15af8d4da01b -->|calls| 0ec6110b_085e_e69b_cc4a_37d966dc5ace ed78da58_8727_ad98_120c_61f35cea357a["walk()"] 0ec6110b_085e_e69b_cc4a_37d966dc5ace -->|calls| ed78da58_8727_ad98_120c_61f35cea357a 36be1773_d660_31ac_0b0b_88dbd7f6f7a8["styleRule()"] 0ec6110b_085e_e69b_cc4a_37d966dc5ace -->|calls| 36be1773_d660_31ac_0b0b_88dbd7f6f7a8 7ba77268_84c7_7083_8f22_251a4a791d25["parseVariant()"] 0ec6110b_085e_e69b_cc4a_37d966dc5ace -->|calls| 7ba77268_84c7_7083_8f22_251a4a791d25 adc16be1_fc13_4928_7caf_2acb3a5e9877["applyVariant()"] 0ec6110b_085e_e69b_cc4a_37d966dc5ace -->|calls| adc16be1_fc13_4928_7caf_2acb3a5e9877 style 0ec6110b_085e_e69b_cc4a_37d966dc5ace fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/variants.ts lines 1210–1235
export function substituteAtVariant(ast: AstNode[], designSystem: DesignSystem): Features {
let features = Features.None
walk(ast, (variantNode) => {
if (variantNode.kind !== 'at-rule' || variantNode.name !== '@variant') return
// Starting with the `&` rule node
let node = styleRule('&', variantNode.nodes)
let variant = variantNode.params
let variantAst = designSystem.parseVariant(variant)
if (variantAst === null) {
throw new Error(`Cannot use \`@variant\` with unknown variant: ${variant}`)
}
let result = applyVariant(node, variantAst, designSystem.variants)
if (result === null) {
throw new Error(`Cannot use \`@variant\` with variant: ${variant}`)
}
// Update the variant at-rule node, to be the `&` rule node
features |= Features.Variants
return WalkAction.Replace(node)
})
return features
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does substituteAtVariant() do?
substituteAtVariant() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/variants.ts.
Where is substituteAtVariant() defined?
substituteAtVariant() is defined in packages/tailwindcss/src/variants.ts at line 1210.
What does substituteAtVariant() call?
substituteAtVariant() calls 4 function(s): applyVariant, parseVariant, styleRule, walk.
What calls substituteAtVariant()?
substituteAtVariant() is called by 3 function(s): buildDesignSystem, fromAst, parseCss.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free