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
  ec55634f_f6e4_3b8b_1267_0b251c4dade1["printCandidate()"]
  a896a263_4e30_1cb1_c3fc_567fec112fbd["printUnprefixedCandidate()"]
  a896a263_4e30_1cb1_c3fc_567fec112fbd -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  c0ed9081_e732_ecfa_0427_6bc0211bcee4["migrateArbitraryVariants()"]
  c0ed9081_e732_ecfa_0427_6bc0211bcee4 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  39857840_c6e7_0594_122a_445c1ca9d108["migrateAutomaticVarInjection()"]
  39857840_c6e7_0594_122a_445c1ca9d108 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  dea7ced9_f1f5_2ff1_f4bc_f35a2d35ce09["migrateCamelcaseInNamedValue()"]
  dea7ced9_f1f5_2ff1_f4bc_f35a2d35ce09 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  e186eef0_e5f2_5d47_3825_19ab57be2de9["migrateLegacyArbitraryValues()"]
  e186eef0_e5f2_5d47_3825_19ab57be2de9 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  4ed0d823_ca6a_b1cd_308d_86008a627784["migrateLegacyClasses()"]
  4ed0d823_ca6a_b1cd_308d_86008a627784 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  486b36da_67cd_fb5a_cf7f_c5aca1c480be["migrateModernizeArbitraryValues()"]
  486b36da_67cd_fb5a_cf7f_c5aca1c480be -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  faeb1e90_cf89_2804_6ef1_386b3a9ffaba["migratePrefix()"]
  faeb1e90_cf89_2804_6ef1_386b3a9ffaba -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  0b5eaab6_9345_179e_f96e_cde6155e1ac1["migrateVariantOrder()"]
  0b5eaab6_9345_179e_f96e_cde6155e1ac1 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  045602b5_3428_1ab2_4022_86cb43c8ffe7["createCanonicalizeCandidateCache()"]
  045602b5_3428_1ab2_4022_86cb43c8ffe7 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  19312e09_c0b9_b4d3_7181_315ee63b4c14["createCanonicalizeUtilityCache()"]
  19312e09_c0b9_b4d3_7181_315ee63b4c14 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  2038620e_696f_2a0a_ba6b_40f989551872["printUnprefixedCandidate()"]
  2038620e_696f_2a0a_ba6b_40f989551872 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  a65f8d6f_368a_80d1_0677_401c085c0a5b["arbitraryUtilities()"]
  a65f8d6f_368a_80d1_0677_401c085c0a5b -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  025cd786_c6cd_4dc8_21b2_25bd225f52f3["allVariablesAreUsed()"]
  025cd786_c6cd_4dc8_21b2_25bd225f52f3 -->|calls| ec55634f_f6e4_3b8b_1267_0b251c4dade1
  style ec55634f_f6e4_3b8b_1267_0b251c4dade1 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(':')
}

Subdomains

Frequently Asked Questions

What does printCandidate() do?
printCandidate() is a function in the tailwindcss codebase.
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