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

Relationship Graph

Source Code

packages/@tailwindcss-cli/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
}

Domain

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free