buildCustomContainerUtilityRules() — tailwindcss Function Reference
Architecture documentation for the buildCustomContainerUtilityRules() function in container.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 06d695a5_21e2_adf5_352b_954581b3e1c0["buildCustomContainerUtilityRules()"] 7a8b38fe_f674_f253_e4c8_9043c8b072e0["container.ts"] 06d695a5_21e2_adf5_352b_954581b3e1c0 -->|defined in| 7a8b38fe_f674_f253_e4c8_9043c8b072e0 253815a9_405f_ff30_32b6_577fe2d91fb2["migrateTheme()"] 253815a9_405f_ff30_32b6_577fe2d91fb2 -->|calls| 06d695a5_21e2_adf5_352b_954581b3e1c0 f0f6f497_52ca_80ac_6d1a_579038582e5b["registerContainerCompat()"] f0f6f497_52ca_80ac_6d1a_579038582e5b -->|calls| 06d695a5_21e2_adf5_352b_954581b3e1c0 1369a6dc_e395_347d_5d24_b88e22c5446d["decl()"] 06d695a5_21e2_adf5_352b_954581b3e1c0 -->|calls| 1369a6dc_e395_347d_5d24_b88e22c5446d 57d66c17_eb5b_fe95_af7d_9e6608d52384["compareBreakpoints()"] 06d695a5_21e2_adf5_352b_954581b3e1c0 -->|calls| 57d66c17_eb5b_fe95_af7d_9e6608d52384 2f6881be_62d9_4b96_7331_a962ced095f7["atRule()"] 06d695a5_21e2_adf5_352b_954581b3e1c0 -->|calls| 2f6881be_62d9_4b96_7331_a962ced095f7 style 06d695a5_21e2_adf5_352b_954581b3e1c0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/compat/container.ts lines 22–120
export function buildCustomContainerUtilityRules(
{
center,
padding,
screens,
}: {
center?: boolean
padding?: string | {}
screens?: {}
},
designSystem: DesignSystem,
): AstNode[] {
let rules = []
let breakpointOverwrites: null | Map<string, AtRule> = null
if (center) {
rules.push(decl('margin-inline', 'auto'))
}
if (
typeof padding === 'string' ||
(typeof padding === 'object' && padding !== null && 'DEFAULT' in padding)
) {
rules.push(
decl('padding-inline', typeof padding === 'string' ? padding : (padding.DEFAULT as string)),
)
}
if (typeof screens === 'object' && screens !== null) {
breakpointOverwrites = new Map()
// When setting the `screens` in v3, you were overwriting the default
// screens config. To do this in v4, you have to manually unset all core
// screens.
let breakpoints = Array.from(designSystem.theme.namespace('--breakpoint').entries())
breakpoints.sort((a, z) => compareBreakpoints(a[1], z[1], 'asc'))
if (breakpoints.length > 0) {
let [key] = breakpoints[0]
// Unset all default breakpoints
rules.push(
atRule('@media', `(width >= --theme(--breakpoint-${key}))`, [decl('max-width', 'none')]),
)
}
for (let [key, value] of Object.entries(screens)) {
if (typeof value === 'object') {
if ('min' in value) {
value = value.min
} else {
continue
}
}
// We're inlining the breakpoint values because the screens configured in
// the `container` option do not have to match the ones defined in the
// root `screen` setting.
breakpointOverwrites.set(
key,
atRule('@media', `(width >= ${value})`, [decl('max-width', value)]),
)
}
}
if (typeof padding === 'object' && padding !== null) {
let breakpoints = Object.entries(padding)
.filter(([key]) => key !== 'DEFAULT')
.map(([key, value]) => {
return [key, designSystem.theme.resolveValue(key, ['--breakpoint']), value]
})
.filter(Boolean) as [string, string, string][]
breakpoints.sort((a, z) => compareBreakpoints(a[1], z[1], 'asc'))
for (let [key, , value] of breakpoints) {
if (breakpointOverwrites && breakpointOverwrites.has(key)) {
let overwrite = breakpointOverwrites.get(key)!
overwrite.nodes.push(decl('padding-inline', value))
} else if (breakpointOverwrites) {
// The breakpoint does not exist in the overwritten breakpoints list, so
// we skip rendering it.
continue
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does buildCustomContainerUtilityRules() do?
buildCustomContainerUtilityRules() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/compat/container.ts.
Where is buildCustomContainerUtilityRules() defined?
buildCustomContainerUtilityRules() is defined in packages/tailwindcss/src/compat/container.ts at line 22.
What does buildCustomContainerUtilityRules() call?
buildCustomContainerUtilityRules() calls 3 function(s): atRule, compareBreakpoints, decl.
What calls buildCustomContainerUtilityRules()?
buildCustomContainerUtilityRules() is called by 2 function(s): migrateTheme, registerContainerCompat.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free