What is the official v4 way to do the v3 max-w-screen-* #20353
|
Hello, And I wonder what is the recommended way to achieve the same results in v4. But I am not sure if this is considered workaround because it uses CSS variable and if there is any more "official" way to do it. So what is the current correct way to do this? |
Replies: 3 comments
|
I see nothing wrong with using @theme {
--max-width-screen-lg: var(--breakpoint-lg);
} |
|
The also the docs recommend |
|
max-w-screen-* was removed in Tailwind CSS v4. The recommended replacement is to use the breakpoint CSS variables: This is the official v4 approach, not a workaround. There is currently no max-w-breakpoint-lg utility. |
max-w-(--breakpoint-lg)is not a workaround, it's intended--breakpoint-*are theme variables emitted to:root, andmax-w-(--some-var)is the documented syntax for pulling a theme variable into a utility (no built-inmax-w-breakpoint-*class in v4)The
@themesnippet from wongjn worksalso the docs recommend
@theme inlinewhen a theme variable references another variable, and baremax-w-screenalready exists in v4 meaningmax-width: 100vw