-
Notifications
You must be signed in to change notification settings - Fork 5.3k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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 and React 19 #6585
Comments
Goat 🐐 |
I actually don't like the sonner toast but okay 👍 |
Great, thanks! |
thanks a lot @shadcn ! tested with a fresh nextjs and vite setup and it worked correctly. |
Thanks |
Tested with react router v7 and it works perfectly! Thank you @shadcn 🙏 |
Woohoo! Thanks @shadcn! |
Needed to import "path" in step 5: pnpm install --save-dev @types/node |
Any advice for remix+vite?
|
Thanks for the update! It works with a clean Vite + React Router V7 setup, however I don't get asked whether to use new-york or default styles in the CLI, and just get new-york @shadcn Also, changing the |
Am I able to upgrade to stable release if i start with these canary version? |
Does this means shadcn will not work with React 18 and older versions? |
Is there a shadcn tailwind v4 monorepo example somewhere? just wondering if there is a documented way to achieve this, or an example repo somewhere? |
Thanks for the great work, is there an estimated time for the official release? I really want to use the latest version in the production environment of the latest project, but there is no official release, some concerns. @shadcn |
This feature introduces a options on the theme generation page, allowing users to select their target Tailwind CSS version (<v4 or v4+). This ensures that the generated CSS is compatible with the user's project. Previously, the theme generator only produced CSS compatible with older Tailwind versions, which caused issues for users on v4. This change addresses those compatibility problems. The implementation involves modifying the CSS generation logic to handle the differences between Tailwind versions. Specifically, v4 requires the use of `@theme inline` and `hsl()` wrappers for color values. The selected version is used to determine the correct CSS syntax. This change improves the user experience by providing a more flexible and robust theme generation process.
why is |
I'm following the Next.js instructions and getting this error on the second command: #Start a new project with Tailwind v4 and React 19: #Init shadcn/ui. This will create your components.json and set up your CSS variables: No import alias found in your tsconfig.json file. |
I'm wondering if theres an update on this |
Nice to see support for TW4 🚀. Seems like the Button is not consistent across browsers. For example in in chrome/brave browser the button text is bolder than it is on Firefox. Also the button text seems to be not centered vertically (see image below). I checked and Shadcn with TW3 does not have these issues. EDIT: Also it seems the hand pointer cursor is not being set on the Button. (EDIT: Just found a solution for this in the upgrade guide: https://tailwindcss.com/docs/upgrade-guide#buttons-use-the-default-cursor) |
Probably just for the future. |
I don't know if this is intentional, but the This can be fixed by adding |
Input.tsx has some duplicated classNames around the aria classnames.
|
Update: I'm going through the comments and addressing the issues. Keep them coming and thank you. |
SidebarProvider is still using forwardRef |
I ran |
My |
I'm performing migrations manually. Is there any guide on how to migrate over my new components.json file? Preferably a new JSON schema link. |
The Geist font isn't working in the demo v4.shadcn.com |
Not sure it is known, but clicking on sidebar edges is not making it smaller. Once you update blocks to tailwind 4/the new shadcn/ui, you will see this. I was using code similar to the first block and got this. |
I had a fresh install for a new project. I get an error every time I add a component because adding a component puts
in my index.css... however with fresh tailwind4 with shadcnui/canary instructions, there is no tailwind.config.js to define border-border and this causes an error. For now, working around by just manually deleting this block so there is no default styling on components. Just using my own inline styling on each component. |
Testing locally, is |
@shadcn So I'm using |
Buttons don't have a
|
Not sure if you were responding to me, but my issues is for all components. |
@kangpeter5 I was not responding to you, sorry. 🙁 🙂 |
We're using turborepo and would love an update on this. |
@elijaholmos Here is the new components.json from the v4 website, you could find all the V4 code (css, config, components) in https://github.com/shadcn-ui/ui/blob/main/apps/v4/components.json |
For some reason borders are not applied to any component, this is my globals.css @plugin "tailwindcss-animate";
@custom-variant dark (&:is(.dark *));
:root {
--card: hsl(0 0% 100%);
--card-foreground: hsl(222.2 84% 4.9%);
--popover: hsl(0 0% 100%);
--popover-foreground: hsl(222.2 84% 4.9%);
--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%);
--muted: hsl(210 40% 96.1%);
--muted-foreground: hsl(215.4 16.3% 46.9%);
--accent: hsl(210 40% 96.1%);
--accent-foreground: hsl(222.2 47.4% 11.2%);
--destructive: hsl(0 84.2% 60.2%);
--destructive-foreground: hsl(210 40% 98%);
--border: hsl(214.3 31.8% 91.4%);
--input: hsl(214.3 31.8% 91.4%);
--ring: hsl(222.2 84% 4.9%);
--chart-1: hsl(12 76% 61%);
--chart-2: hsl(173 58% 39%);
--chart-3: hsl(197 37% 24%);
--chart-4: hsl(43 74% 66%);
--chart-5: hsl(27 87% 67%);
--radius: 0.6rem;
--sidebar: oklch(0.985 0 0);
--sidebar-foreground: oklch(0.145 0 0);
--sidebar-primary: oklch(0.205 0 0);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.97 0 0);
--sidebar-accent-foreground: oklch(0.205 0 0);
--sidebar-border: oklch(0.922 0 0);
--sidebar-ring: oklch(0.87 0 0);
--background: hsl(0 0% 100%);
--foreground: hsl(222.2 84% 4.9%);
}
.dark {
--background: hsl(222.2 84% 4.9%);
--foreground: hsl(210 40% 98%);
--card: hsl(222.2 84% 4.9%);
--card-foreground: hsl(210 40% 98%);
--popover: hsl(222.2 84% 4.9%);
--popover-foreground: hsl(210 40% 98%);
--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%);
--muted: hsl(217.2 32.6% 17.5%);
--muted-foreground: hsl(215 20.2% 65.1%);
--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%);
--border: hsl(217.2 32.6% 17.5%);
--input: hsl(217.2 32.6% 17.5%);
--ring: hsl(212.7 26.8% 83.9%);
--chart-1: hsl(220 70% 50%);
--chart-2: hsl(160 60% 45%);
--chart-3: hsl(30 80% 55%);
--chart-4: hsl(280 65% 60%);
--chart-5: hsl(340 75% 55%);
--sidebar: oklch(0.205 0 0);
--sidebar-foreground: oklch(0.985 0 0);
--sidebar-primary: oklch(0.488 0.243 264.376);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.269 0 0);
--sidebar-accent-foreground: oklch(0.985 0 0);
--sidebar-border: oklch(0.269 0 0);
--sidebar-ring: oklch(0.439 0 0);
}
@theme inline {
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-destructive-foreground: var(--destructive-foreground);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--color-chart-1: var(--chart-1);
--color-chart-2: var(--chart-2);
--color-chart-3: var(--chart-3);
--color-chart-4: var(--chart-4);
--color-chart-5: var(--chart-5);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--color-sidebar: var(--sidebar);
--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);
}
@layer base {
* {
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
}``` |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
It’s here! Tailwind v4 and React 19. Ready for you to try out.
TLDR
If you're starting a new project with Tailwind v4 and React 19, use the
canary
version of the command-line:What's New
canary
) can now initialize projects with Tailwind v4.@theme
directive and@theme inline
option.data-slot
attribute for styling.toast
component in favor ofsonner
.default
style. New projects will usenew-york
.Note: this is non-breaking. Your existing apps with Tailwind v3 and React 18 will still work. When you add new components, they'll still be in v3 and React 18. Only new projects start with v4 and React 19.
What's Coming Next
The following is still being worked on. I'll post updates here.
See it Live
I put together a demo with all the updated components here: https://v4.shadcn.com
Take a look and test the components. If you find any bugs, leave a comment below.
Try It Out
You can test Tailwind v4 + React 19 today using the
canary
release of the CLI.I'm still working on the docs, but here's a quick guide to testing new projects:
Next.js
components.json
and set up your CSS variables:Vite
Follow the official guide to add Tailwind CSS: https://tailwindcss.com/docs/installation/using-vite
Add path aliases to
tsconfig.json
:tsconfig.app.json
:@types/node
:vite.config.ts
:shadcn/ui
. This will create yourcomponents.json
and set up your CSS variables:(Note: If you need help with other frameworks, drop a comment below. I'll update the guide)
Upgrade Your Project
One of the major advantages of using
shadcn/ui
is that the code you end up with is exactly what you'd write yourself. There are no hidden abstractions.This means when a dependency has a new release, you can just follow the official upgrade paths.
Here's how to upgrade your existing projects (full docs are on the way):
1. Follow the Tailwind v4 Upgrade Guide
@tailwindcss/upgrade@next
codemod to remove deprecated utility classes and update tailwind config.2. Update your CSS variables
The codemod will migrate your CSS variables as references under the
@theme
directive.This works. But to make it easier to work with colors and other variables, we'll need to move the
hsl
wrappers and use@theme inline
.Here's how you do it:
:root
and.dark
out of the@layer
base.hsl()
inline
option to@theme
i.e@theme inline {
hsl()
wrappers from@theme
This change makes it much simpler to access your theme variables in both utility classes and outside of CSS for eg. using color values in JavaScript.
3. Update colors for charts
Now that the theme colors come with
hsl()
, you can remove the wrapper in yourchartConfig
:Use new
size-*
utilityThe new
size-*
utility (added in Tailwind v3.4), is now fully supported bytailwind-merge
. You can replacew-* h-*
with the newsize-*
utility:Update your dependencies
pnpm up "@radix-ui/*" cmdk lucide-react recharts tailwind-merge clsx --latest
Remove forwardRef
You can use the
preset-19
codemod to migrate yourforwardRef
to props or manually update the primitives.For the codemod, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#typescript-changes.
If you want to do it manually, here's how to do it step by step:
React.forwardRef<...>
withReact.ComponentProps<...>
ref={ref}
from the component.data-slot
attribute. This will come in handy for styling with Tailwind.displayName
.Before
After
Share Your Feedback
We’d love for you to test these updates and share your feedback! If you run into anything weird or have suggestions, add a comment below.
The text was updated successfully, but these errors were encountered: