{"record":{"id":"a2b96a05e1670882","repo":"tailwindlabs/tailwindcss","slug":"you-cannot-apply-the-candidate-utility-her","errorCode":null,"errorMessage":"You cannot `@apply` the `${candidate}` utility here because it creates a circular dependency.","messagePattern":"You cannot `@apply` the `(.+?)` utility here because it creates a circular dependency\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/apply.ts","lineNumber":115,"sourceCode":"        node.kind === 'at-rule' &&\n        node.name === '@utility' &&\n        next.kind === 'at-rule' &&\n        next.name === '@utility'\n      ) {\n        walk(node.nodes, (child) => {\n          if (child.kind !== 'at-rule' || child.name !== '@apply') return\n\n          let candidates = child.params.split(/\\s+/g)\n          for (let candidate of candidates) {\n            for (let candidateAstNode of designSystem.parseCandidate(candidate)) {\n              switch (candidateAstNode.kind) {\n                case 'arbitrary':\n                  break\n\n                case 'static':\n                case 'functional':\n                  if (next.params.replace(/-\\*$/, '') === candidateAstNode.root) {\n                    throw new Error(\n                      `You cannot \\`@apply\\` the \\`${candidate}\\` utility here because it creates a circular dependency.`,\n                    )\n                  }\n                  break\n\n                default:\n                  candidateAstNode satisfies never\n              }\n            }\n          }\n        })\n      }\n\n      // Generic fallback error in case we cannot properly detect the origin of\n      // the circular dependency.\n      throw new Error(\n        `Circular dependency detected:\\n\\n${toCss([node])}\\nRelies on:\\n\\n${toCss([next])}`,\n      )","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/apply.ts#L97-L133","documentation":"While building the dependency graph for `@utility` ordering, the walker inspects `@apply` rules inside each `@utility`. If a utility's `@apply` references its own root name (after stripping a trailing `-*`), that is a direct self-reference and throws a specific, actionable circular-dependency message. This is the targeted detection before the generic cycle fallback (error 18).","triggerScenarios":"`@utility btn { @apply btn-primary; }` where `btn-primary` resolves to the same root, or a utility that `@apply`s itself: `@utility foo { @apply foo; }`. At apply.ts:115, when `next.params.replace(/-\\*$/,'') === candidateAstNode.root`, it throws naming the offending candidate.","commonSituations":"Renaming a utility and forgetting to update a self-`@apply`, or splitting a utility into variants where one variant references the parent root.","solutions":["Remove the self-referential `@apply`; a utility already has its own styles.","If composing variants, reference a different utility root or inline the shared declarations.","Rename so the `@apply` candidate no longer matches the owning utility's root."],"exampleFix":"/* before */\n@utility btn-primary {\n  @apply btn-primary;\n  background: blue;\n}\n\n/* after */\n@utility btn-primary {\n  background: blue;\n}","handlingStrategy":"validation","validationCode":"function assertNoSelfApply(utilityName: string, applyParams: string) {\n  const root = utilityName.replace(/-\\*$/, '')\n  for (const candidate of applyParams.split(/\\s+/)) {\n    if (candidate === root) {\n      throw new Error(`@utility ${utilityName} cannot @apply itself (${candidate})`)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never @apply a utility inside its own definition.","When renaming utilities, update internal @apply references.","Prefer inlining shared declarations over self-composition."],"tags":["apply","circular-dependency","utility"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}