{"record":{"id":"0cd96221c76cd30b","repo":"tailwindlabs/tailwindcss","slug":"you-have-one-or-more-stylesheets-that-are-imported","errorCode":null,"errorMessage":"You have one or more stylesheets that are imported into a utility layer and non-utility layer.\nWe cannot convert stylesheets under these conditions. Please look at the following stylesheets:\n${lines.join('\\n')}","messagePattern":"You have one or more stylesheets that are imported into a utility layer and non-utility layer\\.\nWe cannot convert stylesheets under these conditions\\. Please look at the following stylesheets:\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts","lineNumber":301,"sourceCode":"      // flag from each leaf.\n      for (let [parent, children] of commonParents) {\n        parent.isTailwindRoot = true\n\n        for (let child of children) {\n          if (parent === child) continue\n\n          child.isTailwindRoot = false\n        }\n      }\n      return\n    }\n  }\n\n  {\n    let error = `You have one or more stylesheets that are imported into a utility layer and non-utility layer.\\n`\n    error += `We cannot convert stylesheets under these conditions. Please look at the following stylesheets:\\n`\n\n    throw new Error(error + lines.join('\\n'))\n  }\n}\n","sourceCodeStart":283,"sourceCodeEnd":304,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts#L283-L304","documentation":"During upgrade, the CSS analyzer tags each stylesheet as imported into a `utilities` layer, a non-utility layer, or both. Tailwind v4 requires a stylesheet to belong consistently to one layer category so it can rewrite `@tailwind utilities` semantics. If the same stylesheet is imported once into a utility layer and once elsewhere, the rewrite is ambiguous and the upgrade aborts with the offending stylesheet list.","triggerScenarios":"A `styles.css` imported both as `@import 'x.css' layer(utilities)` and again as a plain `@import 'x.css'` (or into a different named layer) within the same project. The analyzer collects `lines` of offending imports and analyze.ts:301 throws.","commonSituations":"Shared/partial CSS files pulled into multiple layers across an app, or a design-system CSS imported both into Tailwind's utilities layer and a component layer.","solutions":["Consolidate each stylesheet to a single layer usage: import it into either the utilities layer or a regular layer, not both.","Split the shared stylesheet into two files (one per layer) if both contexts are genuinely needed.","Re-run the upgrade once the duplicate-layer imports are removed."],"exampleFix":"/* before */\n@import \"./shared.css\" layer(utilities);\n@import \"./shared.css\";\n\n/* after */\n@import \"./shared-utils.css\" layer(utilities);\n@import \"./shared-base.css\";","handlingStrategy":"validation","validationCode":"// Audit stylesheet layer usage before upgrade\nfunction findDuplicateLayerImports(cssFiles: { file: string; css: string }[]) {\n  const seen = new Map<string, Set<string>>()\n  for (const { file, css } of cssFiles) {\n    for (const m of css.matchAll(/@import\\s+[\"']([^\"']+)[\"'](?:\\s+layer\\(([^)]+)\\))?/g)) {\n      const [, target, layer] = m\n      const layers = seen.get(target) ?? new Set()\n      const tag = layer ? `layer:${layer}` : 'layer:none'\n      if (layers.has('mixed') || (layers.size && ![...layers].includes(tag) && (layer === 'utilities' || [...layers].some(l => l === 'layer:utilities')))) {\n        console.warn(`Duplicate-layer import: ${target} in ${file}`)\n      }\n      layers.add(tag); seen.set(target, layers)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import each stylesheet into exactly one layer context.","Split shared CSS into per-layer files.","Audit @import ... layer(utilities) usage before running upgrade."],"tags":["upgrade","css-layers","stylesheet-analysis"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}