Home / Function/ printCandidate() — tailwindcss Function Reference

printCandidate() — tailwindcss Function Reference

Architecture documentation for the printCandidate() function in candidate.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  87ba7eab_3a52_d53e_dfd4_e507e9763b55["printCandidate()"]
  669e6a28_c71f_3c5e_9c53_915cede7da78["candidate.ts"]
  87ba7eab_3a52_d53e_dfd4_e507e9763b55 -->|defined in| 669e6a28_c71f_3c5e_9c53_915cede7da78
  d025118b_695c_16f1_a950_06fba5dd3c77["printUnprefixedCandidate()"]
  d025118b_695c_16f1_a950_06fba5dd3c77 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  bc19ae8d_4f83_e280_be05_e35eee14b3e7["migrateArbitraryVariants()"]
  bc19ae8d_4f83_e280_be05_e35eee14b3e7 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  aeb7589b_9d5b_312e_4558_4df754cbb905["migrateAutomaticVarInjection()"]
  aeb7589b_9d5b_312e_4558_4df754cbb905 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  32c3141d_1d0a_d72e_1a76_a960011fba35["migrateCamelcaseInNamedValue()"]
  32c3141d_1d0a_d72e_1a76_a960011fba35 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  2d17c912_6324_fc2c_8ab3_065595647555["migrateLegacyArbitraryValues()"]
  2d17c912_6324_fc2c_8ab3_065595647555 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  155d1c0d_2551_0baf_c0ce_75204772c9a3["migrateLegacyClasses()"]
  155d1c0d_2551_0baf_c0ce_75204772c9a3 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  9f73b711_0f71_129f_7fdb_764a3c0df282["migrateModernizeArbitraryValues()"]
  9f73b711_0f71_129f_7fdb_764a3c0df282 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  087d2224_9aa6_c6e5_3a75_d99cf251cb04["migratePrefix()"]
  087d2224_9aa6_c6e5_3a75_d99cf251cb04 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  4b9b4a6d_0786_22dc_60cb_a53dc01dd582["migrateVariantOrder()"]
  4b9b4a6d_0786_22dc_60cb_a53dc01dd582 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  e5cfde3f_0bc0_3155_68b2_7635f9cbb320["createCanonicalizeCandidateCache()"]
  e5cfde3f_0bc0_3155_68b2_7635f9cbb320 -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  c46276e2_6ad6_12ab_aac8_03ff3271cb1b["createCanonicalizeUtilityCache()"]
  c46276e2_6ad6_12ab_aac8_03ff3271cb1b -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  ef14c2ee_6e22_8d81_5706_eb9d2b37035d["printUnprefixedCandidate()"]
  ef14c2ee_6e22_8d81_5706_eb9d2b37035d -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  1fde95ca_8980_95b5_3738_6b5133f8ff3e["arbitraryUtilities()"]
  1fde95ca_8980_95b5_3738_6b5133f8ff3e -->|calls| 87ba7eab_3a52_d53e_dfd4_e507e9763b55
  style 87ba7eab_3a52_d53e_dfd4_e507e9763b55 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/candidate.ts lines 907–967

export function printCandidate(designSystem: DesignSystem, candidate: Candidate) {
  let parts: string[] = []

  for (let variant of candidate.variants) {
    parts.unshift(printVariant(variant))
  }

  // Handle prefix
  if (designSystem.theme.prefix) {
    parts.unshift(designSystem.theme.prefix)
  }

  let base: string = ''

  // Handle static
  if (candidate.kind === 'static') {
    base += candidate.root
  }

  // Handle functional
  if (candidate.kind === 'functional') {
    base += candidate.root

    if (candidate.value) {
      if (candidate.value.kind === 'arbitrary') {
        if (candidate.value !== null) {
          let isVarValue = isVar(candidate.value.value)
          let value = isVarValue ? candidate.value.value.slice(4, -1) : candidate.value.value
          let [open, close] = isVarValue ? ['(', ')'] : ['[', ']']

          if (candidate.value.dataType) {
            base += `-${open}${candidate.value.dataType}:${printArbitraryValue(value)}${close}`
          } else {
            base += `-${open}${printArbitraryValue(value)}${close}`
          }
        }
      } else if (candidate.value.kind === 'named') {
        base += `-${candidate.value.value}`
      }
    }
  }

  // Handle arbitrary
  if (candidate.kind === 'arbitrary') {
    base += `[${candidate.property}:${printArbitraryValue(candidate.value)}]`
  }

  // Handle modifier
  if (candidate.kind === 'arbitrary' || candidate.kind === 'functional') {
    base += printModifier(candidate.modifier)
  }

  // Handle important
  if (candidate.important) {
    base += '!'
  }

  parts.push(base)

  return parts.join(':')
}

Domain

Subdomains

Frequently Asked Questions

What does printCandidate() do?
printCandidate() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/candidate.ts.
Where is printCandidate() defined?
printCandidate() is defined in packages/tailwindcss/src/candidate.ts at line 907.
What does printCandidate() call?
printCandidate() calls 4 function(s): isVar, printArbitraryValue, printModifier, printVariant.
What calls printCandidate()?
printCandidate() is called by 19 function(s): allVariablesAreUsed, arbitraryUtilities, arbitraryValueToBareValueUtility, bareValueUtilities, buildDesignSystem, createCanonicalizeCandidateCache, createCanonicalizeUtilityCache, dropUnnecessaryDataTypes, and 11 more.

Analyze Your Own Codebase

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

Try Supermodel Free