Skip to content

Migration to v4 css based config #13813

Closed Answered by wongjn
matagaralph asked this question in Help
Discussion options

You must be logged in to vote

I could specify colors as backgroundColors, borderColors, and stroke separately. What's the equivalent of this in v4? Could you provide an example?

The equivalents are:

v3 v4
backgroundColor.key --background-color-<key>: <value>
borderColor.key --border-color-<key>: <value>

See this Tailwind Play


Also, how can I define my colors for both dark and light modes in the same config file using CSS variables?

You could consider using the light-dark() function like:

@import "tailwindcss";

@theme {
  --color-foo: light-dark(white, black);
}

Or you could use the prefers-color-scheme media query like:

@import "tailwindcss";

@theme {
  --color-foo: white;
}

@media (prefers-color-s…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@matagaralph
Comment options

Answer selected by matagaralph
Comment options

You must be logged in to vote
1 reply
@wongjn
Comment options

wongjn May 2, 2025
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants