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
  ae7c115f_7716_cd13_a2b3_1f18f0fb894b["wordWrap()"]
  8715b8e3_2ef0_3a5f_beb9_7129d3febc3e["renderer.ts"]
  ae7c115f_7716_cd13_a2b3_1f18f0fb894b -->|defined in| 8715b8e3_2ef0_3a5f_beb9_7129d3febc3e
  536d70f5_8cf8_3fe4_a1c5_0a1bd03cddb7["help()"]
  536d70f5_8cf8_3fe4_a1c5_0a1bd03cddb7 -->|calls| ae7c115f_7716_cd13_a2b3_1f18f0fb894b
  style ae7c115f_7716_cd13_a2b3_1f18f0fb894b 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