{"record":{"id":"4d812e55f058363b","repo":"tailwindlabs/tailwindcss","slug":"the-spacing-function-requires-an-argument-bu","errorCode":null,"errorMessage":"The --spacing(…) function requires an argument, but received none.","messagePattern":"The --spacing\\(…\\) function requires an argument, but received none\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/css-functions.ts","lineNumber":50,"sourceCode":"  }\n\n  if (rest.length > 0) {\n    throw new Error(\n      `The --alpha(…) function only accepts one argument, e.g.: \\`--alpha(${color || 'var(--my-color)'} / ${alpha || '50%'})\\``,\n    )\n  }\n\n  return withAlpha(color, alpha)\n}\n\nfunction spacing(\n  designSystem: DesignSystem,\n  _source: AstNode,\n  value: string,\n  ...rest: string[]\n): string {\n  if (!value) {\n    throw new Error(`The --spacing(…) function requires an argument, but received none.`)\n  }\n\n  if (rest.length > 0) {\n    throw new Error(\n      `The --spacing(…) function only accepts a single argument, but received ${rest.length + 1}.`,\n    )\n  }\n\n  let multiplier = designSystem.theme.resolve(null, ['--spacing'])\n  if (!multiplier) {\n    throw new Error(\n      'The --spacing(…) function requires that the `--spacing` theme variable exists, but it was not found.',\n    )\n  }\n\n  // Optimization:\n  //\n  // - We know that at this point the `--spacing` value must be set.","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/css-functions.ts#L32-L68","documentation":"Thrown by the `--spacing(...)` CSS function handler when no argument was supplied (`!value`). The function multiplies the theme's `--spacing` base by the supplied length, so an empty call like `--spacing()` has nothing to compute. It is the v4 equivalent of the spacing multiplier behind utilities like `p-4`.","triggerScenarios":"Writing `--spacing()` with empty parentheses, or passing a value that trims to an empty string. The first positional arg becomes `value`; if it is falsy the error fires before the multiplier lookup.","commonSituations":"Typo leaving the parens empty; dynamically generated CSS that interpolates an empty variable into `--spacing(${x})` where `x` is undefined.","solutions":["Pass a length value, e.g. `--spacing(4)` or `--spacing(1.5rem)`.","If the value is dynamic, guard it so an empty/undefined variable is not interpolated into the function.","Remember `--spacing(0)` and `--spacing(1)` are optimized specially — they are valid inputs."],"exampleFix":"/* before */\n.x { padding: --spacing(); }\n/* after */\n.x { padding: --spacing(4); }","handlingStrategy":"validation","validationCode":"function assertSpacingArg(inner: string): void {\n  if (inner.trim() === '') {\n    throw new Error('--spacing requires a length argument');\n  }\n}","typeGuard":"function hasSpacingArgument(inner: string): boolean {\n  return inner.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always pass a length to --spacing(...).","Guard dynamic interpolation: --spacing(${value ?? '0'}).","Lint for empty --spacing() calls."],"tags":["tailwind-v4","css-function","spacing","theme"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}