{"record":{"id":"1ce99047be2818dd","repo":"tailwindlabs/tailwindcss","slug":"the-spacing-function-only-accepts-a-single-ar","errorCode":null,"errorMessage":"The --spacing(…) function only accepts a single argument, but received ${rest.length + 1}.","messagePattern":"The --spacing\\(…\\) function only accepts a single argument, but received (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/css-functions.ts","lineNumber":54,"sourceCode":"      `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.\n  // - We know that `--spacing` must be set to a `<length>` unit, such as `0.25rem`\n  // - We can assume that the `--spacing` value is not set to a `0`-like value.\n  //   Otherwise `p-<anything>` would calculate as `0` which wouldn't make sense.\n  //","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/css-functions.ts#L36-L72","documentation":"Thrown by the `--spacing(...)` handler when more than one argument is supplied (`rest.length > 0`). `--spacing` accepts a single multiplier value only, so extra comma-separated arguments are rejected. The error message interpolates the actual count via `rest.length + 1` so the user sees the real number received.","triggerScenarios":"Writing `--spacing(4, 2)`, `--spacing(1rem, fallback)`, or any call where the function parser produces trailing top-level arguments beyond the first.","commonSituations":"Assuming `--spacing` supports a fallback like `var()`; copy-paste from `clamp(min, pref, max)` patterns; trailing comma.","solutions":["Pass exactly one argument, e.g. `--spacing(4)`.","If you intended a fallback, wrap at the CSS level: `var(--spacing(4), 1rem)` is not supported — instead compute the fallback outside the function.","For multi-value spacing use separate `--spacing(...)` calls or a `calc()` expression."],"exampleFix":"/* before */\n.x { padding: --spacing(4, 2); }\n/* after */\n.x { padding: --spacing(4); }","handlingStrategy":"validation","validationCode":"function assertSingleSpacingArg(inner: string): void {\n  const count = inner.split(',').length;\n  if (count > 1) throw new Error(`--spacing got ${count} args, expected 1`);\n}","typeGuard":"function isSingleSpacingArgument(inner: string): boolean {\n  return inner.split(',').length === 1;\n}","tryCatchPattern":null,"preventionTips":["Pass exactly one argument to --spacing.","Do not try to give --spacing a fallback via extra args.","Use calc() to combine multiple spacing values."],"tags":["tailwind-v4","css-function","spacing","argument-error"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}