Home / Function/ createSpacingCache() — tailwindcss Function Reference

createSpacingCache() — tailwindcss Function Reference

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

Function typescript Oxide Extractor calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  ee814b5e_14e2_34f8_20d7_5683eb2bb8eb["createSpacingCache()"]
  f6c14bbb_2e42_58cc_18f1_c89a243da9c0["canonicalize-candidates.ts"]
  ee814b5e_14e2_34f8_20d7_5683eb2bb8eb -->|defined in| f6c14bbb_2e42_58cc_18f1_c89a243da9c0
  26169039_1fd2_e320_1f63_11ec10a6fc52["prepareDesignSystemStorage()"]
  26169039_1fd2_e320_1f63_11ec10a6fc52 -->|calls| ee814b5e_14e2_34f8_20d7_5683eb2bb8eb
  61e3cc2e_05f1_77a0_19e8_82b9e0fa97a8["resolveThemeValue()"]
  ee814b5e_14e2_34f8_20d7_5683eb2bb8eb -->|calls| 61e3cc2e_05f1_77a0_19e8_82b9e0fa97a8
  f875e425_9644_1071_3601_45e7c7f789d3["constantFoldDeclaration()"]
  ee814b5e_14e2_34f8_20d7_5683eb2bb8eb -->|calls| f875e425_9644_1071_3601_45e7c7f789d3
  2820372c_b982_9e06_fc23_f8f4ac308d00["get()"]
  ee814b5e_14e2_34f8_20d7_5683eb2bb8eb -->|calls| 2820372c_b982_9e06_fc23_f8f4ac308d00
  style ee814b5e_14e2_34f8_20d7_5683eb2bb8eb 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
  })
}

Domain

Subdomains

Frequently Asked Questions

What does createSpacingCache() do?
createSpacingCache() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/canonicalize-candidates.ts.
Where is createSpacingCache() defined?
createSpacingCache() is defined in packages/tailwindcss/src/canonicalize-candidates.ts at line 937.
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