expand() — tailwindcss Function Reference
Architecture documentation for the expand() function in brace-expansion.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 1f29c0ee_be09_f644_3fb8_8d80057c5d97["expand()"] 26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c["parseCss()"] 26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c -->|calls| 1f29c0ee_be09_f644_3fb8_8d80057c5d97 18ccf8d0_0754_3385_ba3d_739fd86e9969["isSequence()"] 1f29c0ee_be09_f644_3fb8_8d80057c5d97 -->|calls| 18ccf8d0_0754_3385_ba3d_739fd86e9969 86796617_8567_a2d8_d154_f31f20830948["expandSequence()"] 1f29c0ee_be09_f644_3fb8_8d80057c5d97 -->|calls| 86796617_8567_a2d8_d154_f31f20830948 2a20ea29_c850_cd61_5600_aeebbe3dda66["segment()"] 1f29c0ee_be09_f644_3fb8_8d80057c5d97 -->|calls| 2a20ea29_c850_cd61_5600_aeebbe3dda66 style 1f29c0ee_be09_f644_3fb8_8d80057c5d97 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