Home / Function/ relative() — tailwindcss Function Reference

relative() — tailwindcss Function Reference

Architecture documentation for the relative() function in renderer.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  a4d70660_306b_669c_4b1c_828588c6371c["relative()"]
  dc1d7e71_14d1_dd51_5d14_8265f9e59cce["migrateJsConfig()"]
  dc1d7e71_14d1_dd51_5d14_8265f9e59cce -->|calls| a4d70660_306b_669c_4b1c_828588c6371c
  5987acc9_de8e_d765_ba48_301e64c09fab["migratePostCSSConfig()"]
  5987acc9_de8e_d765_ba48_301e64c09fab -->|calls| a4d70660_306b_669c_4b1c_828588c6371c
  4d72f15c_1184_4396_0a3a_6a120fe36ae0["analyze()"]
  4d72f15c_1184_4396_0a3a_6a120fe36ae0 -->|calls| a4d70660_306b_669c_4b1c_828588c6371c
  9dd8f849_c8e1_2210_efce_8cd2e70a472c["linkConfigs()"]
  9dd8f849_c8e1_2210_efce_8cd2e70a472c -->|calls| a4d70660_306b_669c_4b1c_828588c6371c
  ac975fa0_6dfb_5b95_d79d_ea10cebf80a5["prepareConfig()"]
  ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 -->|calls| a4d70660_306b_669c_4b1c_828588c6371c
  505fd744_81c1_a3d8_bae0_2cbba00f74d3["detectConfigPath()"]
  505fd744_81c1_a3d8_bae0_2cbba00f74d3 -->|calls| a4d70660_306b_669c_4b1c_828588c6371c
  c1db9de2_3654_d42b_b9f2_1c5a0ccbd307["run()"]
  c1db9de2_3654_d42b_b9f2_1c5a0ccbd307 -->|calls| a4d70660_306b_669c_4b1c_828588c6371c
  style a4d70660_306b_669c_4b1c_828588c6371c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/utils/renderer.ts lines 23–38

export function relative(
  to: string,
  from = process.cwd(),
  { preferAbsoluteIfShorter = true } = {},
) {
  let result = path.relative(from, to)
  if (!result.startsWith('..')) {
    result = `.${path.sep}${result}`
  }

  if (preferAbsoluteIfShorter && result.length > to.length) {
    return to
  }

  return result
}

Subdomains

Frequently Asked Questions

What does relative() do?
relative() is a function in the tailwindcss codebase.
What calls relative()?
relative() is called by 7 function(s): analyze, detectConfigPath, linkConfigs, migrateJsConfig, migratePostCSSConfig, prepareConfig, run.

Analyze Your Own Codebase

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

Try Supermodel Free