{"record":{"id":"424f74ab511c58ee","repo":"tailwindlabs/tailwindcss","slug":"invalid-custom-property-expected-a-value","errorCode":null,"errorMessage":"Invalid custom property, expected a value","messagePattern":"Invalid custom property, expected a value","errorType":"exception","errorClass":"CssSyntaxError","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/css-parser.ts","lineNumber":298,"sourceCode":"\n        // End of a block.\n        else if (\n          peekChar === CLOSE_PAREN ||\n          peekChar === CLOSE_BRACKET ||\n          peekChar === CLOSE_CURLY\n        ) {\n          if (\n            closingBracketStack.length > 0 &&\n            input[j] === closingBracketStack[closingBracketStack.length - 1]\n          ) {\n            closingBracketStack = closingBracketStack.slice(0, -1)\n          }\n        }\n      }\n\n      let declaration = parseDeclaration(buffer, colonIdx)\n      if (!declaration) {\n        throw new CssSyntaxError(\n          `Invalid custom property, expected a value`,\n          source ? [source, start, i] : null,\n        )\n      }\n\n      if (source) {\n        declaration.src = [source, start, i]\n        declaration.dst = [source, start, i]\n      }\n\n      if (parent) {\n        parent.nodes.push(declaration)\n      } else {\n        ast.push(declaration)\n      }\n\n      buffer = ''\n    }","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/css-parser.ts#L280-L316","documentation":"Thrown by the CSS parser while scanning a custom property (a declaration whose name starts with `--`). After collecting the value up to the terminating `}` or end-of-input, it calls `parseDeclaration(buffer, colonIdx)`; if that returns null the declaration is unparseable (typically because the value is empty or malformed) and the parser raises a `CssSyntaxError` with source-location metadata. The message specifically flags custom properties because they have relaxed value rules — failing to parse one usually means the value is missing entirely.","triggerScenarios":"Writing `--my-var: ;` with an empty value at the end of a block without a semicolon, or `--my-var:` followed immediately by `}`, or a custom property whose value consists only of a malformed token the declaration parser rejects. The branch is reached specifically for `--`-prefixed declarations (custom properties).","commonSituations":"Author error leaving a custom property value blank; a broken `@property` override; generated CSS that emits `--x:` with no value; minifier or preprocessor stripping a value.","solutions":["Give the custom property a concrete value, e.g. `--my-var: #fff;`.","If the value is intentionally empty/invalid, use a valid placeholder like `--my-var: initial;`.","Terminate the declaration with a semicolon and ensure the value is non-empty before the closing brace.","Check generated/templated CSS to confirm the value slot is populated."],"exampleFix":"/* before */\n.x {\n  --brand-color:\n}\n/* after */\n.x {\n  --brand-color: #3b82f6;\n}","handlingStrategy":"validation","validationCode":"// Reject empty custom property values before sending CSS to Tailwind\nfunction validateCustomProperties(css: string): string[] {\n  const errors: string[] = [];\n  for (const m of css.matchAll(/(--[\\w-]+)\\s*:\\s*(?:;|\\}|$)/gm)) {\n    errors.push(`Empty value for custom property ${m[1]}`);\n  }\n  return errors;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const ast = CSS.parse(input);\n} catch (e) {\n  if (e instanceof CssSyntaxError && e.message.includes('Invalid custom property')) {\n    // surface the source line, offer a fix\n  } else throw e;\n}","preventionTips":["Always give custom properties a concrete or `initial` value.","Run a CSS linter (stylelint) before compiling.","When templating, ensure value slots are non-empty."],"tags":["tailwind-v4","css-parser","custom-property","syntax-error"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}