Home / Function/ createSpacingCache() — tailwindcss Function Reference

createSpacingCache() — tailwindcss Function Reference

Architecture documentation for the createSpacingCache() function in canonicalize-candidates.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  6a318dee_41f9_3a09_3876_c73653eb7c29["createSpacingCache()"]
  20406e7c_6ee8_4626_dbef_5b37708f4d30["prepareDesignSystemStorage()"]
  20406e7c_6ee8_4626_dbef_5b37708f4d30 -->|calls| 6a318dee_41f9_3a09_3876_c73653eb7c29
  e512528a_2506_964d_514b_bab67f99b575["resolveThemeValue()"]
  6a318dee_41f9_3a09_3876_c73653eb7c29 -->|calls| e512528a_2506_964d_514b_bab67f99b575
  9df707f7_aef8_37b0_5f90_edacde047f5b["constantFoldDeclaration()"]
  6a318dee_41f9_3a09_3876_c73653eb7c29 -->|calls| 9df707f7_aef8_37b0_5f90_edacde047f5b
  4cd99e59_ac1e_2a1f_0946_33cc1afd2532["get()"]
  6a318dee_41f9_3a09_3876_c73653eb7c29 -->|calls| 4cd99e59_ac1e_2a1f_0946_33cc1afd2532
  style 6a318dee_41f9_3a09_3876_c73653eb7c29 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/canonicalize-candidates.ts lines 937–965

function createSpacingCache(
  designSystem: DesignSystem,
  options?: CanonicalizeOptions,
): DesignSystem['storage'][typeof SPACING_KEY] {
  let spacingMultiplier = designSystem.resolveThemeValue('--spacing')
  if (spacingMultiplier === undefined) return null

  spacingMultiplier = constantFoldDeclaration(spacingMultiplier, options?.rem ?? null)

  let parsed = dimensions.get(spacingMultiplier)
  if (!parsed) return null

  let [value, unit] = parsed

  return new DefaultMap<string, number | null>((input) => {
    // If we already know that the spacing multiplier is 0, all spacing
    // multipliers will also be 0. No need to even try and parse/canonicalize
    // the input value.
    if (value === 0) return null

    let parsed = dimensions.get(constantFoldDeclaration(input, options?.rem ?? null))
    if (!parsed) return null

    let [myValue, myUnit] = parsed
    if (myUnit !== unit) return null

    return myValue / value
  })
}

Subdomains

Frequently Asked Questions

What does createSpacingCache() do?
createSpacingCache() is a function in the tailwindcss codebase.
What does createSpacingCache() call?
createSpacingCache() calls 3 function(s): constantFoldDeclaration, get, resolveThemeValue.
What calls createSpacingCache()?
createSpacingCache() is called by 1 function(s): prepareDesignSystemStorage.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free