Skip to content
Open
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
22 changes: 20 additions & 2 deletions packages/shadcn/src/registry/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ describe("configWithDefaults", () => {
expect(result.style).toBe(FALLBACK_STYLE)
})

it("should use FALLBACK_STYLE when style is default and tailwind.config is empty", () => {
const config = createConfig({
style: "default",
tailwind: {
config: "",
css: "app/globals.css",
baseColor: "slate",
cssVariables: true,
},
})

const result = configWithDefaults(config)

expect(result.style).toBe(FALLBACK_STYLE)
})

it("should keep new-york style when tailwind.config is not empty", () => {
const config = createConfig({
style: "new-york",
Expand All @@ -77,11 +93,11 @@ describe("configWithDefaults", () => {
expect(result.style).toBe("new-york")
})

it("should preserve non-new-york styles regardless of tailwind config", () => {
it("should preserve legacy default style when tailwind.config is not empty", () => {
const config1 = createConfig({
style: "default",
tailwind: {
config: "",
config: "tailwind.config.js",
css: "app/globals.css",
baseColor: "slate",
cssVariables: true,
Expand All @@ -90,7 +106,9 @@ describe("configWithDefaults", () => {

const result1 = configWithDefaults(config1)
expect(result1.style).toBe("default")
})

it("should preserve custom styles regardless of tailwind config", () => {
const config2 = createConfig({
style: "miami",
tailwind: {
Expand Down
5 changes: 4 additions & 1 deletion packages/shadcn/src/registry/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ function resolveStyleFromConfig(config: DeepPartial<Config>) {

// Check if we should use new-york-v4 for Tailwind v4.
// We assume that if tailwind.config is empty, we're using Tailwind v4.
if (config.style === "new-york" && config.tailwind?.config === "") {
if (
(config.style === "default" || config.style === "new-york") &&
config.tailwind?.config === ""
) {
return FALLBACK_STYLE
}

Expand Down
Loading