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
  6228667b_758c_4d4c_8d69_6e8bafcbaef9["wordWrap()"]
  b53ee5b3_ea99_2734_8356_c51cb2541f61["help()"]
  b53ee5b3_ea99_2734_8356_c51cb2541f61 -->|calls| 6228667b_758c_4d4c_8d69_6e8bafcbaef9
  style 6228667b_758c_4d4c_8d69_6e8bafcbaef9 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
}

Domain

Subdomains

Called By

Frequently Asked Questions

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