expand() — tailwindcss Function Reference
Architecture documentation for the expand() function in brace-expansion.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 1926c33e_3a42_f5fb_dd2f_a9422b055595["expand()"] 95cb326e_6b59_0903_0c96_d221fca5c2b1["parseCss()"] 95cb326e_6b59_0903_0c96_d221fca5c2b1 -->|calls| 1926c33e_3a42_f5fb_dd2f_a9422b055595 d840de9a_a12f_b876_42e0_6699e05ff2be["isSequence()"] 1926c33e_3a42_f5fb_dd2f_a9422b055595 -->|calls| d840de9a_a12f_b876_42e0_6699e05ff2be 80023148_d915_5237_d1f6_de80ccd2adb7["expandSequence()"] 1926c33e_3a42_f5fb_dd2f_a9422b055595 -->|calls| 80023148_d915_5237_d1f6_de80ccd2adb7 03b8d706_a876_a776_0056_186ced5d6067["segment()"] 1926c33e_3a42_f5fb_dd2f_a9422b055595 -->|calls| 03b8d706_a876_a776_0056_186ced5d6067 style 1926c33e_3a42_f5fb_dd2f_a9422b055595 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/utils/brace-expansion.ts lines 5–53
export function expand(pattern: string): string[] {
let index = pattern.indexOf('{')
if (index === -1) return [pattern]
let result: string[] = []
let pre = pattern.slice(0, index)
let rest = pattern.slice(index)
// Find the matching closing brace
let depth = 0
let endIndex = rest.lastIndexOf('}')
for (let i = 0; i < rest.length; i++) {
let char = rest[i]
if (char === '{') {
depth++
} else if (char === '}') {
depth--
if (depth === 0) {
endIndex = i
break
}
}
}
if (endIndex === -1) {
throw new Error(`The pattern \`${pattern}\` is not balanced.`)
}
let inside = rest.slice(1, endIndex)
let post = rest.slice(endIndex + 1)
let parts: string[]
if (isSequence(inside)) {
parts = expandSequence(inside)
} else {
parts = segment(inside, ',')
}
parts = parts.flatMap((part) => expand(part))
let expandedTail = expand(post)
for (let tail of expandedTail) {
for (let part of parts) {
result.push(pre + part + tail)
}
}
return result
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does expand() do?
expand() is a function in the tailwindcss codebase.
What does expand() call?
expand() calls 3 function(s): expandSequence, isSequence, segment.
What calls expand()?
expand() is called by 1 function(s): parseCss.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free