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

Tailwind v4 Support #1527

Closed
1 task done
oneezy opened this issue Nov 30, 2024 · 9 comments
Closed
1 task done

Tailwind v4 Support #1527

oneezy opened this issue Nov 30, 2024 · 9 comments
Labels
type: feature Introduction of new functionality to the application

Comments

@oneezy
Copy link

oneezy commented Nov 30, 2024

Prerequisites

  • This feature already exists in shadcn/ui - if not, it won't be considered here so don't continue with your issue.

Describe the feature

Tailwind v4 just hit beta release an no breaking changes are expected. Would be cool to see a guide for shadcn-svelte on how to make the switch for some v3 users

(honestly not sure if it exists yet in shadcn but it will)

@oneezy oneezy added the type: feature Introduction of new functionality to the application label Nov 30, 2024
@ieedan
Copy link
Contributor

ieedan commented Nov 30, 2024

shadcn-ui/ui#5949

@ieedan
Copy link
Contributor

ieedan commented Nov 30, 2024

Saying no breaking changes is a bit misleading here I believe they mean no breaking style changes but the config changes are pretty massive.

@huntabyte
Copy link
Owner

This feature already exists in shadcn/ui - if not, it won't be considered here so don't continue with your issue.

@huntabyte huntabyte closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2024
@oneezy
Copy link
Author

oneezy commented Nov 30, 2024

Saying no breaking changes is a bit misleading here I believe they mean no breaking style changes but the config changes are pretty massive.

to clarify @ieedan , i meant no more breaking changes to be expected in tw v4 development (according to Adam).

tw v3 to v4 is a breaking change but it simplifies using tw tremendously.

Tailwind UI website has been fully migrated to v4

image

@nrjdalal
Copy link

for now, if you guys want to use tailwind v4 compatible with any new or existing app, it is pretty simple

just run the codemod -

npx @tailwindcss/upgrade@next

so now the thing is you won't be able to add new components, as there won't be tailwind.config.js/ts anymore, so how do you add new components to your app?

just create a temporary new project and run -

npx shadcn@latest init -d
npx shadcn@latest add -a
npx @tailwindcss/upgrade@next

and voila, you have a new tailwind v4 version of the components and css, just copy and paste required content


if you wish to get this task automated, via CLI tool, feel free to emojify this comment and I will make one

@epavanello
Copy link

epavanello commented Dec 12, 2024

If anyone is interested, i converted the default shadcdn-svelte configuration.
This should be the css-first configuration

@import 'tailwindcss';
@plugin 'tailwindcss-animate';

:root {
	--background: hsl(0 0% 100%);
	--foreground: hsl(222.2 84% 4.9%);
	--muted: hsl(210 40% 96.1%);
	--muted-foreground: hsl(215.4 16.3% 46.9%);
	--popover: hsl(0 0% 100%);
	--popover-foreground: hsl(222.2 84% 4.9%);
	--card: hsl(0 0% 100%);
	--card-foreground: hsl(222.2 84% 4.9%);
	--border: hsl(214.3 31.8% 91.4%);
	--input: hsl(214.3 31.8% 91.4%);
	--primary: hsl(222.2 47.4% 11.2%);
	--primary-foreground: hsl(210 40% 98%);
	--secondary: hsl(210 40% 96.1%);
	--secondary-foreground: hsl(222.2 47.4% 11.2%);
	--accent: hsl(210 40% 96.1%);
	--accent-foreground: hsl(222.2 47.4% 11.2%);
	--destructive: hsl(0 72.2% 50.6%);
	--destructive-foreground: hsl(210 40% 98%);
	--ring: hsl(222.2 84% 4.9%);
	--radius: 0.5rem;
	--sidebar-background: hsl(0 0% 98%);
	--sidebar-foreground: hsl(240 5.3% 26.1%);
	--sidebar-primary: hsl(240 5.9% 10%);
	--sidebar-primary-foreground: hsl(0 0% 98%);
	--sidebar-accent: hsl(240 4.8% 95.9%);
	--sidebar-accent-foreground: hsl(240 5.9% 10%);
	--sidebar-border: hsl(220 13% 91%);
	--sidebar-ring: hsl(217.2 91.2% 59.8%);
}

.dark {
	--background: hsl(222.2 84% 4.9%);
	--foreground: hsl(210 40% 98%);
	--muted: hsl(217.2 32.6% 17.5%);
	--muted-foreground: hsl(215 20.2% 65.1%);
	--popover: hsl(222.2 84% 4.9%);
	--popover-foreground: hsl(210 40% 98%);
	--card: hsl(222.2 84% 4.9%);
	--card-foreground: hsl(210 40% 98%);
	--border: hsl(217.2 32.6% 17.5%);
	--input: hsl(217.2 32.6% 17.5%);
	--primary: hsl(210 40% 98%);
	--primary-foreground: hsl(222.2 47.4% 11.2%);
	--secondary: hsl(217.2 32.6% 17.5%);
	--secondary-foreground: hsl(210 40% 98%);
	--accent: hsl(217.2 32.6% 17.5%);
	--accent-foreground: hsl(210 40% 98%);
	--destructive: hsl(0 62.8% 30.6%);
	--destructive-foreground: hsl(210 40% 98%);
	--ring: hsl(212.7 26.8% 83.9%);
	--sidebar-background: hsl(240 5.9% 10%);
	--sidebar-foreground: hsl(240 4.8% 95.9%);
	--sidebar-primary: hsl(224.3 76.3% 48%);
	--sidebar-primary-foreground: hsl(0 0% 100%);
	--sidebar-accent: hsl(240 3.7% 15.9%);
	--sidebar-accent-foreground: hsl(240 4.8% 95.9%);
	--sidebar-border: hsl(240 3.7% 15.9%);
	--sidebar-ring: hsl(217.2 91.2% 59.8%);
}

@theme {
	--color-border: var(--border);
	--color-input: var(--input);
	--color-ring: var(--ring);
	--color-background: var(--background);
	--color-foreground: var(--foreground);
	--color-primary: var(--primary);
	--color-primary-foreground: var(--primary-foreground);
	--color-secondary: var(--secondary);
	--color-secondary-foreground: var(--secondary-foreground);
	--color-destructive: var(--destructive);
	--color-destructive-foreground: var(--destructive-foreground);
	--color-muted: var(--muted);
	--color-muted-foreground: var(--muted-foreground);
	--color-accent: var(--accent);
	--color-accent-foreground: var(--accent-foreground);
	--color-popover: var(--popover);
	--color-popover-foreground: var(--popover-foreground);
	--color-card: var(--card);
	--color-card-foreground: var(--card-foreground) / <alpha-value>;
	--color-sidebar-DEFAULT: var(--sidebar-background);
	--color-sidebar-foreground: var(--sidebar-foreground);
	--color-sidebar-primary: var(--sidebar-primary);
	--color-sidebar-'primary-foreground': var(--sidebar-primary-foreground);
	--color-sidebar-accent: var(--sidebar-accent);
	--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
	--color-sidebar-border: var(--sidebar-border);
	--color-sidebar-ring: var(--sidebar-ring);

	--radius-xl: calc(var(--radius) + 4px);
	--radius-lg: var(--radius);
	--radius-md: calc(var(--radius) - 2px);
	--radius-sm: calc(var(--radius) - 4px);

	--animate-accordion-down: accordion-down 0.2s ease-out;
	--animate-accordion-up: accordion-up 0.2s ease-out;
	--animate-caret-blink: caret-blink 1.25s ease-out infinite;

	@keyframes accordion-down {
		from: {
			height: 0;
		}
		to: {
			height: var(--bits-accordion-content-height);
		}
	}
	@keyframes accordion-up {
		from {
			height: var(--bits-accordion-content-height);
		}
		to {
			height: 0;
		}
	}
	@keyframes caret-blink {
		0%,
		70%,
		100% {
			opacity: 1;
		}
		20%,
		50% {
			opacity: 0;
		}
	}
}

@utility container {
	margin-inline: auto;
	padding-inline: 2rem;
}

@layer base {
	* {
		@apply border-border;
	}
	body {
		@apply bg-background text-foreground;
	}
}

By pasting this content into your app's css, you should be able to delete the tailwind.config.ts file without any differences

@nrjdalal
Copy link

missing @variant for theme toggling in config above

I just whipped out a new CLI tool to experiment with @nextjs, @shadcn and @tailwindcss v4-beta

you can try it too, at npmjs.com/package/shadcnext

@ieedan
Copy link
Contributor

ieedan commented Dec 13, 2024

missing @variant for theme toggling in config above

I just whipped out a new CLI tool to experiment with @nextjs, @shadcn and @tailwindcss v4-beta

you can try it too, at npmjs.com/package/shadcnext

This is a tool for next not svelte

@nrjdalal
Copy link

ohh right, use steps than, should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

5 participants