Home / Function/ spacing() — tailwindcss Function Reference

spacing() — tailwindcss Function Reference

Architecture documentation for the spacing() function in css-functions.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  8ad03eab_f1e5_8d3e_4a1c_ff595badbf98["spacing()"]
  2189e39a_5595_cbd9_3bbe_eaf87ccf42a2["css-functions.ts"]
  8ad03eab_f1e5_8d3e_4a1c_ff595badbf98 -->|defined in| 2189e39a_5595_cbd9_3bbe_eaf87ccf42a2
  style 8ad03eab_f1e5_8d3e_4a1c_ff595badbf98 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/css-functions.ts lines 42–66

function spacing(
  designSystem: DesignSystem,
  _source: AstNode,
  value: string,
  ...rest: string[]
): string {
  if (!value) {
    throw new Error(`The --spacing(…) function requires an argument, but received none.`)
  }

  if (rest.length > 0) {
    throw new Error(
      `The --spacing(…) function only accepts a single argument, but received ${rest.length + 1}.`,
    )
  }

  let multiplier = designSystem.theme.resolve(null, ['--spacing'])
  if (!multiplier) {
    throw new Error(
      'The --spacing(…) function requires that the `--spacing` theme variable exists, but it was not found.',
    )
  }

  return `calc(${multiplier} * ${value})`
}

Domain

Subdomains

Frequently Asked Questions

What does spacing() do?
spacing() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/css-functions.ts.
Where is spacing() defined?
spacing() is defined in packages/tailwindcss/src/css-functions.ts at line 42.

Analyze Your Own Codebase

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

Try Supermodel Free