Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(3/n) shadcn: tailwind config #6490

Merged
merged 19 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-cherries-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn": minor
---

add support for tailwind v4
13 changes: 12 additions & 1 deletion packages/shadcn/src/preflights/preflight-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ export async function preFlightInit(
)}.`
)

const tailwindSpinner = spinner(`Validating Tailwind CSS.`, {
let tailwindSpinnerMessage = "Validating Tailwind CSS."

if (projectInfo.tailwindVersion === "v4") {
tailwindSpinnerMessage = `Validating Tailwind CSS config. Found ${highlighter.info(
"v4"
)}.`
}

const tailwindSpinner = spinner(tailwindSpinnerMessage, {
silent: options.silent,
}).start()
if (
Expand All @@ -93,6 +101,9 @@ export async function preFlightInit(
) {
errors[ERRORS.TAILWIND_NOT_CONFIGURED] = true
tailwindSpinner?.fail()
} else if (!projectInfo.tailwindVersion) {
errors[ERRORS.TAILWIND_NOT_CONFIGURED] = true
tailwindSpinner?.fail()
} else {
tailwindSpinner?.succeed()
}
Expand Down
2 changes: 2 additions & 0 deletions packages/shadcn/src/utils/add-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ async function addProjectComponents(
cleanupDefaultNextStyles: options.isNewProject,
silent: options.silent,
tailwindVersion,
tailwindConfig: tree.tailwind?.config,
})

await updateDependencies(tree.dependencies, config, {
Expand Down Expand Up @@ -176,6 +177,7 @@ async function addWorkspaceComponents(
await updateCssVars(component.cssVars, targetConfig, {
silent: true,
tailwindVersion,
tailwindConfig: component.tailwind?.config,
})
filesUpdated.push(
path.relative(workspaceRoot, targetConfig.resolvedPaths.tailwindCss)
Expand Down
Loading