Home / Function/ wordWrap() — tailwindcss Function Reference

wordWrap() — tailwindcss Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  013ade5d_a705_2dda_2ed9_20a4f95c3a49["wordWrap()"]
  cc1a3f06_4b21_684c_487a_f342bd18d772["renderer.ts"]
  013ade5d_a705_2dda_2ed9_20a4f95c3a49 -->|defined in| cc1a3f06_4b21_684c_487a_f342bd18d772
  b3812df1_363e_a468_d814_9f5366025963["help()"]
  b3812df1_363e_a468_d814_9f5366025963 -->|calls| 013ade5d_a705_2dda_2ed9_20a4f95c3a49
  style 013ade5d_a705_2dda_2ed9_20a4f95c3a49 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-cli/src/utils/renderer.ts lines 43–67

export function wordWrap(text: string, width: number) {
  let words = text.split(' ')
  let lines = []

  let line = ''
  let lineLength = 0
  for (let word of words) {
    let wordLength = stripVTControlCharacters(word).length

    if (lineLength + wordLength + 1 > width) {
      lines.push(line)
      line = ''
      lineLength = 0
    }

    line += (lineLength ? ' ' : '') + word
    lineLength += wordLength + (lineLength ? 1 : 0)
  }

  if (lineLength) {
    lines.push(line)
  }

  return lines
}

Subdomains

Called By

Frequently Asked Questions

What does wordWrap() do?
wordWrap() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-cli/src/utils/renderer.ts.
Where is wordWrap() defined?
wordWrap() is defined in packages/@tailwindcss-cli/src/utils/renderer.ts at line 43.
What calls wordWrap()?
wordWrap() is called by 1 function(s): help.

Analyze Your Own Codebase

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

Try Supermodel Free